This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67371] Never executed "throw" in constexpr function fails to compile
- From: "yalterz at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 14 Aug 2017 10:46:09 +0000
- Subject: [Bug c++/67371] Never executed "throw" in constexpr function fails to compile
- Auto-submitted: auto-generated
- References: <bug-67371-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67371
Иван Молодецких <yalterz at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |yalterz at gmail dot com
--- Comment #14 from Иван Молодецких <yalterz at gmail dot com> ---
(In reply to Matthijs van Duin from comment #13)
> This is still not working for me in g++ 6 and 7:
>
> constexpr void foo( bool ok ) {
> if( ok )
> return;
> throw;
> }
>
> In function ‘constexpr void foo(bool)’:
> error: expression ‘<throw-expression>’ is not a constant-expression
>
>
> Rewriting the code as:
>
> constexpr void foo( bool ok ) {
> if( ok )
> return;
> else
> throw;
> }
>
> gets rid of the error, but this can be really awkward to do in more
> complicated functions.
Confirming this, was wondering why GCC couldn't compile my project while Clang
and MSVC could, and changing the code according to this comment fixed it.