This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug c/50975] Logical operators evaluated in wrong order if no side effects


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50975

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org
         Resolution|                            |INVALID

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-03 21:08:43 UTC ---
> You can tell the difference in execution time.

Execution time isn't a side effect of the abstract machine as defined by the
ISO C standard.  5.1.2.3 reads:

1 The semantic descriptions in this International Standard describe the
behavior
  of an abstract machine in which issues of optimization are irrelevant.

As long as the side-effects are preserved ("as if" rule), this is valid.

> I think this is different from the controversy over the handling of signed
> integer overflow.  There is no undefined behavior here.  The language standard
> from K&R to the present day explicitly states the evaluation order is
> guaranteed left to right with these operators.

Only if there are side-effects, otherwise the "as if" rule can be applied.


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