[Bug c++/96182] GCC accepts constexpr function with no return-statement

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jul 13 11:59:01 GMT 2020


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The difference is that in C++11 the standard requires that the body of a
constexpr function is return expression, that is not the case of C++14 anymore.
And, you'd get an error if you tried constexpr int a = foo (); i.e. when it is
evaluated in constant expression, but when it is only evaluated e.g. in int b =
foo (); it is a problem only at runtime.


More information about the Gcc-bugs mailing list