This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: soft-fp: Use parentheses around macro arguments
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 9 Oct 2014 17:49:12 +0000
- Subject: Re: soft-fp: Use parentheses around macro arguments
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1410091706070 dot 23641 at digraph dot polyomino dot org dot uk> <87k349tabu dot fsf at igel dot home>
On Thu, 9 Oct 2014, Andreas Schwab wrote:
> "Joseph S. Myers" <joseph@codesourcery.com> writes:
>
> > diff --git a/soft-fp/double.h b/soft-fp/double.h
> > index 1e6283e..36a11a5 100644
> > --- a/soft-fp/double.h
> > +++ b/soft-fp/double.h
> > @@ -90,21 +90,21 @@ union _FP_UNION_D
> > };
> >
> > # define FP_DECL_D(X) _FP_DECL (2, X)
> > -# define FP_UNPACK_RAW_D(X, val) _FP_UNPACK_RAW_2 (D, X, val)
> > -# define FP_UNPACK_RAW_DP(X, val) _FP_UNPACK_RAW_2_P (D, X, val)
> > -# define FP_PACK_RAW_D(val, X) _FP_PACK_RAW_2 (D, val, X)
> > +# define FP_UNPACK_RAW_D(X, val) _FP_UNPACK_RAW_2 (D, X, (val))
> > +# define FP_UNPACK_RAW_DP(X, val) _FP_UNPACK_RAW_2_P (D, X, (val))
> > +# define FP_PACK_RAW_D(val, X) _FP_PACK_RAW_2 (D, (val), X)
>
> Why do you need that? Unless you play tricks with a macro expanding to
> a comma it is impossible to put a literal comma in a macro argument
> without hiding it inside parens.
It's true that it's hard for a lack of parentheses to cause problems here
- but it seems prudent just to follow a general rule that arguments (that
are expressions) go in parentheses, to make it obvious to the reader that
things are OK. (In other places, soft-fp *does* use macro arguments that
are macros expanding to contain commas, with a macro where such an
argument is a single argument redirecting to one where it becomes multiple
arguments.)
--
Joseph S. Myers
joseph@codesourcery.com