Bug 10032 - [3.3/3.4 regression] -pedantic converts some errors to warnings
[3.3/3.4 regression] -pedantic converts some errors to warnings
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
3.2.2
: P3 normal
: 3.3.1
Assigned To: Gabriel Dos Reis
: diagnostic
: 7307 8488 11632 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-03-11 21:06 UTC by mvl
Modified: 2004-01-17 04:22 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-05-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mvl 2003-03-11 21:06:00 UTC
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 3 CVS Commits 2003-07-10 16:47:58 UTC
Subject: Bug 10032

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-07-10 16:47:52

Modified files:
	gcc            : ChangeLog 
	gcc/doc        : invoke.texi 
	gcc/cp         : ChangeLog cp-tree.h decl.c error.c tree.c 
	                 typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: pedantic1.C 

Log message:
	PR c++/10032
	* doc/invoke.texi (C++ Dialect Options): Change documentation of
	-fpermissive.
	
	PR c++/10032
	* decl.c (cxx_init_decl_processing): With -pedantic, pedwarns are
	still errors.
	
	PR c++/10527
	* error.c (decl_to_string): Do not print default argument
	expressions.
	
	* cp-tree.h (break_out_calls): Remove declaration.
	* tree.c (break_out_calls): Remove.
	* typeck.c (build_modify_expr): Avoid invalid sharing of trees.
	
	PR c++/10032
	* g++.dg/warn/pedantic1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.439&r2=2.440
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&r1=1.315&r2=1.316
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3506&r2=1.3507
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.871&r2=1.872
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1085&r2=1.1086
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&r1=1.220&r2=1.221
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.335&r2=1.336
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.478&r2=1.479
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2860&r2=1.2861
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/pedantic1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 CVS Commits 2003-07-10 17:05:35 UTC
Subject: Bug 10032

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	2003-07-10 17:05:28

Modified files:
	gcc            : ChangeLog 
	gcc/doc        : invoke.texi 
	gcc/cp         : ChangeLog decl.c error.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: pedantic1.C 

Log message:
	PR c++/10032
	* doc/invoke.texi (C++ Dialect Options): Change documentation of
	-fpermissive.
	
	PR c++/10032
	* decl.c (cxx_init_decl_processing): With -pedantic, pedwarns are
	still errors.
	
	PR c++/10527
	* error.c (decl_to_string): Do not print default argument
	expressions.
	
	PR c++/10032
	* g++.dg/warn/pedantic1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.646&r2=1.16114.2.647
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.209.2.39&r2=1.209.2.40
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.177&r2=1.3076.2.178
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.53&r2=1.965.2.54
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.192.2.6&r2=1.192.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.224&r2=1.2261.2.225
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/pedantic1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

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 Andrew Pinski 2003-07-11 11:59:51 UTC
*** Bug 8488 has been marked as a duplicate of this bug. ***
Comment 7 Andrew Pinski 2003-07-11 12:00:47 UTC
*** Bug 7307 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2003-07-22 17:16:36 UTC
*** Bug 11632 has been marked as a duplicate of this bug. ***