public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Suanhsi Yong <suan@cs.wisc.edu>
To: gcc-gnats@gcc.gnu.org
Subject: c/6409: C comma operator: wrong behavior
Date: Mon, 22 Apr 2002 10:06:00 -0000 [thread overview]
Message-ID: <200204221704.MAA00865@cygnet.cs.wisc.edu> (raw)
>Number: 6409
>Category: c
>Synopsis: C comma operator: wrong behavior
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Apr 22 10:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Suanhsi Yong
>Release: 3.0.3
>Organization:
>Environment:
System: Linux cygnet.cs.wisc.edu 2.4.17-csl1smp #1 SMP Mon Jan 7 16:44:21 CST 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /s/gcc-3.0.3/src/gcc-3.0.3/configure --prefix=/s/gcc-3.0.3/i386_rh72 --enable-shared --enable-threads
Note: bug also manifested in <sparc-sun-solaris2.8> version, and version 3.0.4 (linux) as well.
>Description:
Best illustrated by example:
1. int val;
2. (val=11)
3. + (val=22,
4. printf("VAL = %d\n", val)
5. );
Line 4 outputs "11" rather than the expected "22".
C specs define a sequence point at the comma operator,
so by the "at-most-one-write" semantics of expressions,
val should be 22 at line 4.
(Its value at line 6, of course, is undefined, due to
the arbitrary order-of-evaluation for the + operator.)
>How-To-Repeat:
Just compile (gcc, no special flags needed) and run the following:
int main()
{
int val;
(val=11)
+ (val=22, printf("VAL = %d\n", val));
return 0;
}
>Fix:
Don't know.
>Release-Note:
>Audit-Trail:
>Unformatted:
next reply other threads:[~2002-04-22 17:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-22 10:06 Suanhsi Yong [this message]
2002-04-22 10:16 jsm28
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200204221704.MAA00865@cygnet.cs.wisc.edu \
--to=suan@cs.wisc.edu \
--cc=gcc-gnats@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).