[Dovecot] v1.1.11 released

Jack Bailey jack at internetguy.net
Sat Feb 7 09:31:41 EET 2009


> On Feb 7, 2009, at 1:47 AM, Frank Cusack wrote:
>
>>>     for (i = j = 0;
>>> removed this warning, and removed my doubts :-)
>>
>> Should be
>> for (i = (j = 0);
>>
>> a = b = ... is not legal, although gcc does accept it.
>
> Really? I've seen a=b=c like code for a long time. But I can't say
> exactly where C99 would allow that. Anyway I'd think parenthesis only
> affect precedence ordering, not whether something is allowed or not.
>
> Although there is one example in C99 spec (well, I've only a draft)
> that seems to suggest it's legal:
>
> 5.1.2.3 Environment 5.1.2.3
>
> double d1, d2;
> float f;
> d1 = f = expression;
> d2 = (float) expressions;
> the values assigned to d1 and d2 are required to have been converted
> to float.
>

i = j = 0 is perfectly legal.  I just spent about 1/2 hour going through 
my collection of C language books, plus a scan through a dozen or so web 
pages, and none suggest parens are necessary or even common practice.  
With all the warnings turned on, neither gcc nor Sun Studio 12 complain 
about the lack of parens.  The expression evaluates right to left, and 
so long as the left side of the operator is an lvalue it is valid 
syntax.  See http://docs.hp.com/en/B3901-90007/ch05s03.html for further 
information.

Jack



More information about the dovecot mailing list