This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50975] Logical operators evaluated in wrong order if no side effects
- From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 Nov 2011 21:08:43 +0000
- Subject: [Bug c/50975] Logical operators evaluated in wrong order if no side effects
- Auto-submitted: auto-generated
- References: <bug-50975-4@http.gcc.gnu.org/bugzilla/>
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.