Article View: gnu.gcc.bug
Article #6000documentation bug
From: Kaz Kylheku
Date: Thu, 26 Dec 1996 00:00
Date: Thu, 26 Dec 1996 00:00
28 lines
1821 bytes
1821 bytes
While researching the ``gcc.texi'' file in preparation for my last bug
report (to determine whether the problem was a result of deliberate
non-compliance or a genuine bug), I came across the following:
@example
void func (int, int);
int i = 2;
func (i++, i++);
@end example
There is no guarantee (in either the C or the C++ standard language
definitions) that the increments will be evaluated in any particular
order. Either increment might happen first. @code{func} might get the
arguments @samp{2, 3}, or it might get @samp{3, 2}, or even @samp{2, 2}.
This is incorrect. Yes, in the C language standard, it is written that
the evaluation order of function arguments is unspecified. However, it is
also stated that there is a sequence point before the actual function call
(but not between the argument evaluations), and that the effect of modifying
an object more than once between sequence points is undefined. Hence func(i++,
i++) is UNDEFINED behavior, not UNSPECIFIED behavior. It is therefore false to
say that either increment might happen first: the language description makes
no particular requirements on the translation of undefined behavior.
The function could get 42, 42 yet the compiler could still be
considered conforming.
Technical Details
Message-ID:
<Pine.LNX.3.95.961226123444.428A-100000@bullwinkle>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,43f7abad28e42d08,start X-Google-Attributes: gid113d02,public From: kaz@cafe.net (Kaz Kylheku) Subject: documentation bug Date: 1996/12/26 Message-ID: <Pine.LNX.3.95.961226123444.428A-100000@bullwinkle> X-Deja-AN: 206084077 sender: bug-gcc-request@prep.ai.mit.edu x-sender: kaz@bullwinkle content-type: TEXT/PLAIN; charset=US-ASCII x-gateway: relay7.UU.NET from bug-gcc to gnu.gcc.bug; Thu, 26 Dec 1996 15:39:20 EST mime-version: 1.0 newsgroups: gnu.gcc.bug