Re: [chrony-dev] GCC issue

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


> From: Bill Unruh <unruh@xxxxxxxxxxxxxx>

> > Apparently there is no sequence point with the | operator and the
> > compiler is free to use any order.
> >
> > http://en.wikipedia.org/wiki/Sequence_point
> 
> Lets hope that 
> r=(fprintf()<0) ;
> r|=fclose()
> does not get optimized away by the compiler, and then one runs into the same
> problem.

My understanding is that the fclose() is required to be executed
regardless of the value of r at that point -- "|" is not a
short-circuit operator.

I would like to see the code as:

> r=(fprintf()<0) ;
> r|=(fclose() == EOF);

fclose() returns 0 on success and EOF on failure, and it's generally
not a good idea to use "|" on values whose bit-pattern you do not
understand.

Dale

-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/