Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/constexpr-new.C

raw
1 // { dg-do compile { target c++14 } }
2 // { dg-additional-options "-fdelete-null-pointer-checks" }
3
4 constexpr int *f4(bool b) {
5 if (b) {
6 return nullptr;
7 } else {
8 return new int{42}; // { dg-error "call to non-.constexpr." "" { target c++17_down } }
9 } // { dg-error "is not a constant expression because allocated storage has not been deallocated" "" { target c++2a } .-1 }
10 }
11 static_assert(f4(true) == nullptr, "");
12 static_assert(f4(false) == nullptr, ""); // { dg-error "non-.constant. condition|" }