public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/96057] New: -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition @ 2020-07-04 8:21 haoxintu at gmail dot com 2020-07-04 8:24 ` [Bug c++/96057] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: haoxintu at gmail dot com @ 2020-07-04 8:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96057 Bug ID: 96057 Summary: -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- Hi, all. This small code, bug.cc, the -Wreturn-type warning disappears when add -O1 or higher optimization option. $cat bug.cc namespace { int foo() { 1 ? 0 : throw 0 ; } } $g++ -c -Wreturn-type -O0 bug.cc bug.cc: In function 'int {anonymous}::foo()': bug.cc:2:35: warning: control reaches end of non-void function [-Wreturn-type] 2 | int foo() { 1 ? 0 : throw 0 ; } | $g++ -c -Wreturn-type -O1 bug.cc //emit nothing with -O1 to -Os option While in Clang, the output of -O0 to -Os is the same. For example, $clang++ -c -Wreturn-type -O1 bug.cc bug.cc:2:35: warning: non-void function does not return a value [-Wreturn-type] int foo() { 1 ? 0 : throw 0 ; } ^ 1 warning generated. $g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/ --enable-languages=c,c++ CC=gcc CXX=g++ Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20200630 (experimental) (GCC) ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96057] -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition 2020-07-04 8:21 [Bug c++/96057] New: -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition haoxintu at gmail dot com @ 2020-07-04 8:24 ` pinskia at gcc dot gnu.org 2022-01-05 20:55 ` [Bug c++/96057] [9/10/11/12 Regression] -Wreturn-type warning message disappears with -O1+ in anonymous " pinskia at gcc dot gnu.org 2022-01-21 13:30 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2020-07-04 8:24 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96057 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There was another report about static inline where this happens too. The same reasoning applies here. The function is unused and there for there is no undefined runtime behavior can happen. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96057] [9/10/11/12 Regression] -Wreturn-type warning message disappears with -O1+ in anonymous namespace definition 2020-07-04 8:21 [Bug c++/96057] New: -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition haoxintu at gmail dot com 2020-07-04 8:24 ` [Bug c++/96057] " pinskia at gcc dot gnu.org @ 2022-01-05 20:55 ` pinskia at gcc dot gnu.org 2022-01-21 13:30 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-01-05 20:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96057 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|-Wreturn-type warning |[9/10/11/12 Regression] |message disappears with -O1 |-Wreturn-type warning |to -Os in unnamed namespace |message disappears with |definition |-O1+ in anonymous namespace | |definition Known to fail| |12.0, 4.4.7 Ever confirmed|0 |1 Target Milestone|--- |9.5 Status|UNCONFIRMED |NEW Last reconfirmed| |2022-01-05 Known to work| |4.1.2 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96057] [9/10/11/12 Regression] -Wreturn-type warning message disappears with -O1+ in anonymous namespace definition 2020-07-04 8:21 [Bug c++/96057] New: -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition haoxintu at gmail dot com 2020-07-04 8:24 ` [Bug c++/96057] " pinskia at gcc dot gnu.org 2022-01-05 20:55 ` [Bug c++/96057] [9/10/11/12 Regression] -Wreturn-type warning message disappears with -O1+ in anonymous " pinskia at gcc dot gnu.org @ 2022-01-21 13:30 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2022-01-21 13:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96057 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|NEW |RESOLVED --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- That's because the -Wreturn-type diagnostic happens after we remove unused functions which we only do at -O1+: t.c: At global scope: t.c:2:9: warning: 'int {anonymous}::foo()' defined but not used [-Wunused-function] 2 | int foo() { 1 ? 0 : throw 0 ; } | ^~~ which in turn is because the function is local (in an anonymous namespace). Likely GCC 4.1 removed the function only later. IMHO a WONTFIX, sorry. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-21 13:30 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-07-04 8:21 [Bug c++/96057] New: -Wreturn-type warning message disappears with -O1 to -Os in unnamed namespace definition haoxintu at gmail dot com 2020-07-04 8:24 ` [Bug c++/96057] " pinskia at gcc dot gnu.org 2022-01-05 20:55 ` [Bug c++/96057] [9/10/11/12 Regression] -Wreturn-type warning message disappears with -O1+ in anonymous " pinskia at gcc dot gnu.org 2022-01-21 13:30 ` rguenth at gcc dot gnu.org
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).