Re: 'C' Operators precedence

Allanah Myles (dossy@panoptic.com)
Wed, 20 May 1998 11:37:27 -0400


On 1998.05.20, H. Peter Anvin <hpa@transmeta.com> wrote:
> > ... the compiler may still not legally evaluate the objects
> > in any order because of associativity, but many/most do.
> > Optimization is not yet part of the 'C' standard. When
> > attempting to optimize code, certain standards are broken as
> > long as the code is likely to work.
>
> This is just plain WRONG. The C standard is very explicit that there
> are no sequence points between the evaluation of the arguments of
> addition; in fact, only a few operators have any serialization
> property; && and || does, and maybe (I am not sure about this one) the
> assignment operators.

I agree with hpa here - the behavior that the original author is citing
directly disagrees with the current C standard that I've read, and if
I dig through K&R1 or K&R2, it's probably in there too.

You _may_ be able to ask your compiler through a high level of -O to try
and optimize ignoring the standard so long as it produces "equivalent
output code," but I don't see any real added benefit from the compiler
trying to outsmart the specification. Anytime you're going to try and
produce output from code that is not part of the determinate behavior,
you're asking for trouble. Why should the programmer have to "guess"
how the code they write is going to be interpreted?

-Dossy

-- 
URL: http://www.panoptic.com/~dossy -< BORK BORK! >- E-MAIL: dossy@panoptic.com
    Now I'm who I want to be, where I want to be, doing what I've always said I
    would and yet I feel I haven't won at all...      (Aug 9, 95: Goodbye, JG.)
"You should change your .sig; not that the world revolves around me." -s. sadie

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu