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

--- Comment #7 from Casey Carter <Casey at Carter dot net> ---
(In reply to Markus Trippelsdorf from comment #6)
> Well, my patch survives regression testing and fixes the issue.
> 
> But unfortunately it leads to accept invalid cases like:
> 
> constexpr int f1() {
>   throw;
>   return 0;
> }
> 
> or 
> 
> constexpr void f2() {
>   throw;
> }
> 
> (Even clang accepts f2.)

I think it would be better for the compiler to accept constexpr functions that
are ill-formed NDR - like f1 and f2 - than to reject constexpr functions that
are conforming like:

constexpr int f3() {
  return 0;
  throw;
}

constexpr int* f4(bool b) {
  if (b) { return nullptr; }
  else { return new int{42}; }
}

Reply via email to