public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48087] New: -Wall -Werror adds warnings over and above those generated by -Wall
@ 2011-03-12  6:21 cgd at google dot com
  2011-10-18  0:54 ` [Bug c++/48087] " paolo.carlini at oracle dot com
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: cgd at google dot com @ 2011-03-12  6:21 UTC (permalink / raw)
  To: gcc-bugs

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?"


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2014-01-23  7:21 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-12  6:21 [Bug c++/48087] New: -Wall -Werror adds warnings over and above those generated by -Wall cgd at google dot com
2011-10-18  0:54 ` [Bug c++/48087] " paolo.carlini at oracle dot com
2011-10-18  1:19 ` paolo.carlini at oracle dot com
2011-10-18  1:22 ` paolo.carlini at oracle dot com
2011-10-18  1:30 ` [Bug middle-end/48087] [4.5/4.6/4.7 Regression] " paolo.carlini at oracle dot com
2011-10-18  8:26 ` rguenther at suse dot de
2011-10-18  9:42 ` paolo.carlini at oracle dot com
2011-10-18 15:44 ` manu at gcc dot gnu.org
2011-10-18 16:03 ` paolo.carlini at oracle dot com
2011-10-18 16:10 ` paolo.carlini at oracle dot com
2011-10-18 20:23 ` manu at gcc dot gnu.org
2011-10-18 23:42 ` paolo.carlini at oracle dot com
2011-10-19  1:44 ` manu at gcc dot gnu.org
2011-10-19  7:49 ` rguenther at suse dot de
2011-10-19 15:39 ` paolo.carlini at oracle dot com
2011-10-19 15:53 ` paolo.carlini at oracle dot com
2011-10-19 17:24 ` manu at gcc dot gnu.org
2011-10-19 17:28 ` paolo.carlini at oracle dot com
2011-10-27  9:27 ` rguenth at gcc dot gnu.org
2011-10-27  9:39 ` rguenth at gcc dot gnu.org
2011-10-27 10:21 ` paolo.carlini at oracle dot com
2011-10-27 10:26 ` rguenther at suse dot de
2011-12-06 10:09 ` rguenth at gcc dot gnu.org
2012-07-02 12:23 ` [Bug middle-end/48087] [4.5/4.6/4.7/4.8 " rguenth at gcc dot gnu.org
2013-01-15 15:12 ` [Bug middle-end/48087] [4.6/4.7/4.8 " jakub at gcc dot gnu.org
2013-01-15 16:40 ` manu at gcc dot gnu.org
2013-03-21 20:03 ` [Bug middle-end/48087] [4.6/4.7/4.8/4.9 " jakub at gcc dot gnu.org
2013-04-12 15:18 ` [Bug middle-end/48087] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
2014-01-23  7:21 ` law at redhat dot com

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).