public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/35502] New: -Wall should include -Wswitch-default
@ 2008-03-07 23:19 jeff at schwabcenter dot com
2008-03-07 23:22 ` [Bug debug/35502] " jeff at schwabcenter dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: jeff at schwabcenter dot com @ 2008-03-07 23:19 UTC (permalink / raw)
To: gcc-bugs
The g++ man page says -Wall is equivalent to "All of the above -W
options combined." The -Wswitch-default option should therefore be included in
-Wall, but currently is not.
The correct solution IMO is to add -Wswitch-default to -Wall in c-opts.c.
Please see the attached patch.
Script started on Fri Mar 7 12:16:38 2008
~$ g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --enable-languages=c++
--prefix=/export/home/jeff/opt/gcc
Thread model: posix
gcc version 4.2.4 20080214 (prerelease)
~$ g++ -Wall -Wswitch-default main.cc
main.cc: In function 'int main(int, char**)':
main.cc:1: warning: switch missing default case
~$ g++ -Wall main.cc -save-temps
~$ cat main.ii
# 1 "main.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "main.cc"
int main(int argc, char** argv) { switch (argc) { } }
Script done on Fri Mar 7 12:17:25 2008
--
Summary: -Wall should include -Wswitch-default
Product: gcc
Version: 4.2.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jeff at schwabcenter dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/35502] -Wall should include -Wswitch-default
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
@ 2008-03-07 23:22 ` jeff at schwabcenter dot com
2008-03-07 23:25 ` jeff at schwabcenter dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jeff at schwabcenter dot com @ 2008-03-07 23:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jeff at schwabcenter dot com 2008-03-07 23:21 -------
Created an attachment (id=15277)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15277&action=view)
Preprocessed sample code
Compiling the attached file with g++ -Wall should produce "warning: switch
missing default case".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/35502] -Wall should include -Wswitch-default
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
2008-03-07 23:22 ` [Bug debug/35502] " jeff at schwabcenter dot com
@ 2008-03-07 23:25 ` jeff at schwabcenter dot com
2008-03-07 23:26 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jeff at schwabcenter dot com @ 2008-03-07 23:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jeff at schwabcenter dot com 2008-03-07 23:24 -------
Created an attachment (id=15278)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15278&action=view)
Fix for this bug
Setting warn_switch_default = value in the OPT_Wall case of
c_common_handle_option (in gcc/c-opts.c) fixes the problem.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/35502] -Wall should include -Wswitch-default
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
2008-03-07 23:22 ` [Bug debug/35502] " jeff at schwabcenter dot com
2008-03-07 23:25 ` jeff at schwabcenter dot com
@ 2008-03-07 23:26 ` pinskia at gcc dot gnu dot org
2008-03-07 23:32 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-03-07 23:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2008-03-07 23:26 -------
This is a documentation fix which has already happened, see
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html .
-Wall
This enables all the warnings about constructions that some users consider
questionable, and that are easy to avoid (or modify to prevent the warning),
even in conjunction with macros. This also enables some language-specific
warnings described in C++ Dialect Options and Objective-C and Objective-C++
Dialect Options.
-Wall turns on the following warning flags:
-Waddress
-Warray-bounds (only with -O2)
-Wc++0x-compat
-Wchar-subscripts
-Wimplicit-int
-Wimplicit-function-declaration
-Wcomment
-Wformat
-Wmain (only for C/ObjC and unless -ffreestanding)
-Wmissing-braces
-Wnonnull
-Wparentheses
-Wpointer-sign
-Wreorder
-Wreturn-type
-Wsequence-point
-Wsign-compare (only in C++)
-Wstrict-aliasing
-Wstrict-overflow=1
-Wswitch
-Wtrigraphs
-Wuninitialized (only with -O1 and above)
-Wunknown-pragmas
-Wunused-function
-Wunused-label
-Wunused-value
-Wunused-variable
-Wvolatile-register-var
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/35502] -Wall should include -Wswitch-default
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
` (2 preceding siblings ...)
2008-03-07 23:26 ` pinskia at gcc dot gnu dot org
@ 2008-03-07 23:32 ` pinskia at gcc dot gnu dot org
2008-03-07 23:39 ` jeff at schwabcenter dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-03-07 23:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2008-03-07 23:31 -------
See http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01761.html and
http://archives.free.net.ph/message/20071001.204624.0ca57fae.de.html
.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/35502] -Wall should include -Wswitch-default
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
` (3 preceding siblings ...)
2008-03-07 23:32 ` pinskia at gcc dot gnu dot org
@ 2008-03-07 23:39 ` jeff at schwabcenter dot com
2008-03-07 23:43 ` jeff at schwabcenter dot com
2008-03-07 23:44 ` jeff at schwabcenter dot com
6 siblings, 0 replies; 8+ messages in thread
From: jeff at schwabcenter dot com @ 2008-03-07 23:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jeff at schwabcenter dot com 2008-03-07 23:38 -------
Thanks for the quick response and the links. FYI, the latter link seems to be
broken:
http://archives.free.net.ph/message/20071001.204624.0ca57fae.de.html
Is there any particular reason for changing the docs, rather than the code?
Include Wswitch-default in Wall is intuitive to me, and avoiding the warning is
straight-forward (if not trivial).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/35502] -Wall should include -Wswitch-default
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
` (4 preceding siblings ...)
2008-03-07 23:39 ` jeff at schwabcenter dot com
@ 2008-03-07 23:43 ` jeff at schwabcenter dot com
2008-03-07 23:44 ` jeff at schwabcenter dot com
6 siblings, 0 replies; 8+ messages in thread
From: jeff at schwabcenter dot com @ 2008-03-07 23:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jeff at schwabcenter dot com 2008-03-07 23:42 -------
> Is there any particular reason for changing the docs, rather than the code?
Kindly disregard that question. I have just been informed by a co-worker that
some of our third-party library headers include switch statements without
default cases, so adding -Wswitch-default to -Wall would make our lives more
difficult, anyway. :(
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/35502] -Wall should include -Wswitch-default
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
` (5 preceding siblings ...)
2008-03-07 23:43 ` jeff at schwabcenter dot com
@ 2008-03-07 23:44 ` jeff at schwabcenter dot com
6 siblings, 0 replies; 8+ messages in thread
From: jeff at schwabcenter dot com @ 2008-03-07 23:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jeff at schwabcenter dot com 2008-03-07 23:43 -------
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html does not list
-Wswitch-default being enabled by -Wall.
--
jeff at schwabcenter dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |VERIFIED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35502
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-03-07 23:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07 23:19 [Bug debug/35502] New: -Wall should include -Wswitch-default jeff at schwabcenter dot com
2008-03-07 23:22 ` [Bug debug/35502] " jeff at schwabcenter dot com
2008-03-07 23:25 ` jeff at schwabcenter dot com
2008-03-07 23:26 ` pinskia at gcc dot gnu dot org
2008-03-07 23:32 ` pinskia at gcc dot gnu dot org
2008-03-07 23:39 ` jeff at schwabcenter dot com
2008-03-07 23:43 ` jeff at schwabcenter dot com
2008-03-07 23:44 ` jeff at schwabcenter 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).