http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58848
Bug ID: 58848 Summary: constexpr function allows throw Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mib.bugzilla at gmail dot com Created attachment 31072 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31072&action=edit should get compilation error A simple test case rejects throw inside constexpr function, but a more complicated test case allows the throw. Attaching 2 test cases Bad: g++ constexp_error.cpp -std=c++0x -bash-4.1$ ./a.out fail, exception raised Good: g++ constexp_ok.cpp -std=c++0x constexp_ok.cpp: In function âint main()â: constexp_ok.cpp:15:47: in constexpr expansion of âfum<DUMMY>::numSubEntities<int>(5)â constexp_ok.cpp:8:73: error: expression â<throw-expression>â is not a constant-expression throw std::out_of_range("a point has only subentities of codim=0"); gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/rdrive/ref/gcc/4.8.1/rhel60/efi2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/configure --prefix=/rdrive/ref/gcc/4.8.1/rhel60/efi2 --enable-languages=c,c++,objc,fortran --disable-multilib --enable-bootstrap --target=x86_64-unknown-linux-gnu --disable-bootstrap --enable-decimal-float --with-gmp=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2 --with-mpfr=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2 --with-mpc=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2 Thread model: posix gcc version 4.8.1 (GCC)