gcc/testsuite/g++.dg/cpp2a/constexpr-new24.C
raw| 1 | // PR c++/118775 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | int a; |
| 5 | |
| 6 | constexpr char * |
| 7 | f1 () |
| 8 | { |
| 9 | constexpr auto p = new char[(long int) &a]; // { dg-error "size not constant" } |
| 10 | return p; |
| 11 | } |
| 12 | |
| 13 | constexpr char * |
| 14 | f2 () |
| 15 | { |
| 16 | auto p = new char[(long int) &a]; // { dg-error "size not constant" } |
| 17 | return p; |
| 18 | } |
| 19 | |
| 20 | void |
| 21 | g () |
| 22 | { |
| 23 | auto r1 = f2 (); |
| 24 | constexpr auto r2 = f2 (); // { dg-message "in .constexpr. expansion" } |
| 25 | } |