This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48087] New: -Wall -Werror adds warnings over and above those generated by -Wall
- From: "cgd at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 12 Mar 2011 06:21:00 +0000
- Subject: [Bug c++/48087] New: -Wall -Werror adds warnings over and above those generated by -Wall
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48087
Summary: -Wall -Werror adds warnings over and above those
generated by -Wall
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: cgd@google.com
was checking the status of the code in PR33752 against 4.6, and discovered that
under GCC pre-4.6,
-Wall -Werror
causes more errors/warnings to be generated than just -Wall.
See code an examples below.
This is a bit surprising; certainly, the manual just says:
-Werror
Make all warnings into errors.
the 4.4.x (and earlier) behaviour of stopping earlier (exiting after the first
error, in this example) is not ideal, but IMO is less surprising than having
-Werror *add* errors.
the test input file from PR33752, placed into x.cc:
class Alpha {
public:
Alpha() { }
~Alpha();
};
class Beta {
public:
Beta() { }
~Beta() __attribute__((noreturn));
bool value() { return false; }
};
bool Gamma(bool b) {
return b;
}
bool DeltaOne(bool b) {
Alpha s;
bool b2 = Beta().value();
Gamma(b2);
}
bool DeltaTwo(bool b) {
if (b) {
return false;
} else {
bool b2 = Beta().value();
Gamma(Beta().value());
}
}
bool DeltaThree(bool b) {
Alpha s;
if (b) {
return false;
} else {
bool b2 = Beta().value();
Gamma(b2);
}
}
GCC 4.4.5 (from ftp.gnu.org):
$ inst/bin/gcc --version | head -1
gcc (GCC) 4.4.5
$
$ inst/bin/gcc -c /tmp/x.cc -Wall
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:28: warning: unused variable 'b2'
/tmp/x.cc: In function 'bool DeltaThree(bool)':
/tmp/x.cc:42: warning: control reaches end of non-void function
$
-> 2 warnings.
$ inst/bin/gcc -c /tmp/x.cc -Wall -Werror
cc1plus: warnings being treated as errors
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:28: error: unused variable 'b2'
$
-> 1 error, stopping after the first. not necessarily perfect, but OK.
GCC 4.5.2 (from ftp.gnu.org):
$ inst/bin/gcc --version | head -1
gcc (GCC) 4.5.2
$
$ inst/bin/gcc -c /tmp/x.cc -Wall
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:28:9: warning: unused variable 'b2'
/tmp/x.cc: In function 'bool DeltaThree(bool)':
/tmp/x.cc:42:1: warning: control reaches end of non-void function
$
-> 2 warnings
$ inst/bin/gcc -c /tmp/x.cc -Wall -Werror
cc1plus: warnings being treated as errors
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:28:9: error: unused variable 'b2'
/tmp/x.cc: In function 'bool DeltaThree(bool)':
/tmp/x.cc:42:1: error: control reaches end of non-void function
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:31:1: error: control reaches end of non-void function
/tmp/x.cc: In function 'bool DeltaOne(bool)':
/tmp/x.cc:22:1: error: control reaches end of non-void function
$
-> 4 errors. Huh?
GCC pre-4.6 (svn trunk as of yesterday):
$ inst/bin/gcc --version | head -1
gcc (GCC) 4.6.0 20110311 (experimental)
$
$ inst/bin/gcc -c /tmp/x.cc -Wall
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:28:9: warning: unused variable 'b2' [-Wunused-variable]
/tmp/x.cc: In function 'bool DeltaThree(bool)':
/tmp/x.cc:42:1: warning: control reaches end of non-void function
[-Wreturn-type]
$
-> 2 warnings.
$ inst/bin/gcc -c /tmp/x.cc -Wall -Werror
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:28:9: error: unused variable 'b2' [-Werror=unused-variable]
/tmp/x.cc: In function 'bool DeltaThree(bool)':
/tmp/x.cc:42:1: error: control reaches end of non-void function
[-Werror=return-type]
/tmp/x.cc: In function 'bool DeltaTwo(bool)':
/tmp/x.cc:31:1: error: control reaches end of non-void function
[-Werror=return-type]
/tmp/x.cc: In function 'bool DeltaOne(bool)':
/tmp/x.cc:22:1: error: control reaches end of non-void function
[-Werror=return-type]
cc1plus: all warnings being treated as errors
$
-> 4 errors. Same as 4.6, but still "huh?"