This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Expand mempcpy into memcpy


On 2/6/2013 12:53 PM, Paul Eggert wrote:
> On 02/06/13 09:40, OndÅej BÃlka wrote:
>
>> +     size_t __n = (n);							       \
> A minor point: those parentheses aren't needed.

Put this one on your next programming interview question list!

I had to go double-check the C precedence table to convince myself he was right: the only thing with lower precedence than "=" is ",", and you can't have a "," in a macro argument since it would just end up as a macro argument separator.  And "=" itself is parsed right-to-left unlike most operators, so putting "n" on the LHS without parentheses is therefore safe.

True but tricky - and over the years I've started being more conservative in my use of parentheses, just because it makes the code more maintainable.  In this particular case, I'd agree with OndÅej that just following the standard rule of "parenthesize the use of all macro arguments" is the most maintainable way to write this.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]