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

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