This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/82572] New: throw on line by itself in constexpr function aborts compile even if never reached


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82572

            Bug ID: 82572
           Summary: throw on line by itself in constexpr function aborts
                    compile even if never reached
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ekchew at lgl dot kos.net
  Target Milestone: ---

This code will not compile in C++14:

    constexpr void foo() {
        if(true)
            return;
        throw "What am I doing here?";
    }

Error:

gccbug.cc: In function 'constexpr void foo()':
gccbug.cc:4:8: error: expression '<throw-expression>' is not a constant
expression
  throw "What am I doing here?";
        ^~~~~~~~~~~~~~~~~~~~~~~

Build:

COLLECT_GCC=g++-7
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/7.2.0/libexec/gcc/x86_64-apple-darwin16.7.0/7.2.0/lto-wrapper
Target: x86_64-apple-darwin16.7.0
Configured with: ../configure --build=x86_64-apple-darwin16.7.0
--prefix=/usr/local/Cellar/gcc/7.2.0
--libdir=/usr/local/Cellar/gcc/7.2.0/lib/gcc/7
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-7
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC
7.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--disable-nls --with-native-system-header-dir=/usr/include
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
Thread model: posix
gcc version 7.2.0 (Homebrew GCC 7.2.0)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]