public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7387: gcc 3.1 accepts if (int x = f()) {int x;}
@ 2002-07-23 12:02 gdr
0 siblings, 0 replies; 2+ messages in thread
From: gdr @ 2002-07-23 12:02 UTC (permalink / raw)
To: dobrynin, gcc-bugs, gcc-prs, nobody
Synopsis: gcc 3.1 accepts if (int x = f()) {int x;}
State-Changed-From-To: open->closed
State-Changed-By: gdr
State-Changed-When: Tue Jul 23 12:02:00 2002
State-Changed-Why:
Dup of 2288
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7387
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/7387: gcc 3.1 accepts if (int x = f()) {int x;}
@ 2002-07-23 11:56 dobrynin
0 siblings, 0 replies; 2+ messages in thread
From: dobrynin @ 2002-07-23 11:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 7387
>Category: c++
>Synopsis: gcc 3.1 accepts if (int x = f()) {int x;}
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Tue Jul 23 11:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Nickolai Dobrynin, University of WI-Milwaukee
>Release: gcc version 3.1.1 20020714 (prerelease)
>Organization:
>Environment:
1) Cygwin, Windows 2000, Pentium III:
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.1.1/specs
Configured with: /netrel/src/gcc-3.1.1-3/configure --enable-languages=c,c++,f77,
java --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --wi
thout-included-gettext --disable-shared --enable-interpreter --disable-sjlj-exce
ptions --disable-version-specific-runtime-libs --build=i686-pc-linux --host=i686
-pc-cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/u
sr --sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libex
ecdir=/usr/sbin
Thread model: posix
gcc version 3.1.1 20020714 (prerelease)
******************************
2) Also Mingw on Windows 2000, Pentium III:
Reading specs from C:/progra~1/gcc3.1/bin/../lib/gcc-lib/mingw32/3.1/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable
-languages=f77,c++,objc,ada --disable-win32-registry --disable-shared
Thread model: win32
gcc version 3.1
>Description:
In the following code,
if (int x = f()) {
int x; //erroneously accepted
}
"int x = f()" introduces a new variable 'x'. According to
[6.4], "if the name is re-declared in the outermost block
of a substatement controlled by the condition, the
declaration that re-declares the name is ill-formed".
$ g++ -Wall 6_4bug.cpp
gccbug.cpp: In function `int main()':
gccbug.cpp:6: warning: unused variable `int x'
gccbug.cpp:9: warning: unused variable `int x'
gccbug.cpp:5: warning: unused variable `int x'
>How-To-Repeat:
int f();
int main()
{
if (int x = f()) {
int x; // ill-formed, redeclaration of 'x'
}
else {
int x; // ill-formed, redeclaration of 'x'
}
return 0;
}
int f() {return 0;}
// Compile with g++ -Wall 6_4bug.cpp
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="6_4bug.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="6_4bug.cpp"
aW50IGYoKTsKCmludCBtYWluKCkKewogICBpZiAoaW50IHggPSBmKCkpIHsKICAgICBpbnQgeDsg
ICAvLyBpbGwtZm9ybWVkLCByZWRlY2xhcmF0aW9uIG9mICd4JwogICB9CiAgIGVsc2UgewogICAg
IGludCB4OyAgIC8vIGlsbC1mb3JtZWQsIHJlZGVjbGFyYXRpb24gb2YgJ3gnCiAgIH0KCiAgIHJl
dHVybiAwOwp9CgoKaW50IGYoKSB7cmV0dXJuIDA7fQo=
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-07-23 19:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-23 12:02 c++/7387: gcc 3.1 accepts if (int x = f()) {int x;} gdr
-- strict thread matches above, loose matches on Subject: below --
2002-07-23 11:56 dobrynin
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).