[Bug c++/91000] New: noexcept in constexpr context with std=c++11 and std=c++14

federico.kircheis at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 25 19:19:00 GMT 2019


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

            Bug ID: 91000
           Summary: noexcept in constexpr context with std=c++11 and
                    std=c++14
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.kircheis at gmail dot com
  Target Milestone: ---

I've used following snippet of code for testing if inside a constepxr context:

----
template<class T> constexpr void test_constexpr_helper(T&&) {}
constexpr bool test_fun(bool expr) {
        return noexcept(test_constexpr_helper(expr));
}
static_assert(test_fun(true), "inside static_assert it's always constexpr");
int main(){}
----


But since g++9 (I've tested with different version on compiler explorer, with
-std=c++14 and -std=c++11) this piece of code does not compile anymore.

>From what I've seen from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87603,
the new behaviour is not accidental, at least for -std=c++17.

But since I'm compiling with -std=c++11 and -std=c++14, the code should behave
as it did with g++-8, fro reading the comments further, this breaking change
has not been an accident.


So:
 * Does g++-9 provide a mechanism/extension that also works with c++11 and
c++14? If not, is it possible to restore the "old" behaviour?
 * Is there an extension that works for c++17 too?

Thanks

Federico


More information about the Gcc-bugs mailing list