public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msimons at simons-clan dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/11633] New: g++ does not initialize structures when auto-increment variables are used Date: Tue, 22 Jul 2003 20:53:00 -0000 [thread overview] Message-ID: <20030722205341.11633.msimons@simons-clan.com> (raw) PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11633 Summary: g++ does not initialize structures when auto-increment variables are used Product: gcc Version: 3.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: msimons at simons-clan dot com CC: gcc-bugs at gcc dot gnu dot org int count = 23; int foo[] = { count++, count++, count++ }; results: foo == { 23, 23, 23 }, count == 26; expected: foo == { 23, 24, 25 }, count == 26; === Tested only on intel platform with g++. on debian stable version 2.95.4 and a on Redhat AS 2.1 with a self compiled version 3.3. With g++ 2.96 from Redhat AS 2.1, if foo is a global variable (not inside any function scope), then foo is initialized correctly to different values. Attached to the bug is a simple test program... beta.cc g++ -Wall -g -o beta beta.cc gdb -q ./beta === (gdb) b main Breakpoint 1 at 0x8048674: file beta.cc, line 21. (gdb) r Starting program: ./beta Breakpoint 1, main () at beta.cc:21 21 static_func(); (gdb) p foo $1 = {23, 24, 25} (gdb) p zap $2 = {26, 26, 26} (gdb) s static_func() () at beta.cc:8 8 static int bar[] = { value(), value(), value() }; (gdb) n 9 static int baz[] = { count++, count++, count++ }; (gdb) n 11 return bar[0] + baz[0]; (gdb) p bar $3 = {29, 30, 31} (gdb) p baz $4 = {32, 32, 32} === Notice that the function calls are handled correctly, but the count++ is not. I do not know the c++ standard, it is *possible* that the code above is "undefined" by the standard and what g++ is doing is correct. However, the same code compiled with at least 5 commercial compilers on various platforms all resulted in what I say is the "expected" result with different values.
next reply other threads:[~2003-07-22 20:53 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-07-22 20:53 msimons at simons-clan dot com [this message] 2003-07-22 20:55 ` [Bug c++/11633] " msimons at simons-clan dot com 2003-07-22 21:41 ` bangerth at dealii dot org 2003-07-22 21:55 ` bangerth at dealii dot org 2003-07-22 22:10 ` msimons at simons-clan dot com 2003-07-22 23:19 ` msimons at simons-clan dot com 2003-07-22 23:36 ` bangerth at dealii dot org 2003-07-23 1:09 ` msimons at simons-clan dot com 2003-07-23 9:04 ` nathan at gcc dot gnu dot org 2003-08-23 17:11 ` pinskia at gcc dot gnu dot org 2003-11-21 16:55 ` pinskia at gcc dot gnu dot org 2003-11-21 16:57 ` pinskia at gcc dot gnu dot org 2004-04-30 1:47 ` [Bug c++/11633] [DR 430] " pinskia at gcc dot gnu dot org 2004-04-30 18:17 ` pinskia at gcc dot gnu dot org
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=20030722205341.11633.msimons@simons-clan.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).