10032 – [3.3/3.4 regression] -pedantic converts some errors to warnings (original) (raw)

pedantic gives a warning when a jump jumps over the initialization of a var, but then dies. Without pedantic, is gives an error. The error is ok, but the warning is confusing. It should be an error too.

[michiel@epsilon temp]$ cat goto.cpp int main() { goto label;

int temp = 1;

label: return 1; } [michiel@epsilon temp]$ g++ -pedantic goto.cpp && echo ok goto.cpp: In function int main()': goto.cpp:6: warning: jump to label label' goto.cpp:2: warning: from here goto.cpp:4: crosses initialization of `int temp'

[michiel@epsilon temp]$ g++ goto.cpp && echo ok goto.cpp: In function int main()': goto.cpp:6: jump to label label' goto.cpp:2: from here goto.cpp:4: crosses initialization of `int temp'

[michiel@epsilon temp]$

(expected: echo "ok" when only warnings are given)

Release: 3.2.2 20030109 (Debian prerelease)

Environment: Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux Thread model: posix gcc version 3.2.2 20030109 (Debian prerelease)

Comment 1 Wolfgang Bangerth 2003-03-22 03:59:46 UTC

State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed -- i.e., somehow. The behavior of 3.3 and 3.4 is different, but still confusing: -pedantic converts some errors to warnings, and I really thing that the following doesn't make much sense:

g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
x.cc: In function `int main()':
x.cc:6: error: jump to label `label'
x.cc:2: error:   from here
x.cc:4: error:   crosses initialization of `int temp'
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c -pedantic x.cc
x.cc: In function `int main()':
x.cc:6: warning: jump to label `label'
x.cc:2: warning:   from here
x.cc:4: error:   crosses initialization of `int temp'
g/x> echo $?
1

Comment 2 Giovanni Bajo 2003-05-16 02:00:22 UTC

Responsible-Changed-From-To: unassigned->gdr Responsible-Changed-Why: Diagnostic mantainer.

Comment 5 Mark Mitchell 2003-07-10 17:05:46 UTC

Fixed in GCC 3.3.1, GCC 3.4 with attached patch.

Comment 6 Drea Pinski 2003-07-11 11:59:51 UTC

*** Bug 8488 has been marked as a duplicate of this bug. ***

Comment 7 Drea Pinski 2003-07-11 12:00:47 UTC

*** Bug 7307 has been marked as a duplicate of this bug. ***

Comment 8 Drea Pinski 2003-07-22 17:16:36 UTC

*** Bug 11632 has been marked as a duplicate of this bug. ***