Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-new25.C

raw
1 // PR c++/118775
2 // { dg-do compile { target c++20 } }
3
4 namespace std {
5 struct __uniq_ptr_impl {
6 constexpr __uniq_ptr_impl(char *) {}
7 };
8 template <typename> struct unique_ptr {
9 __uniq_ptr_impl _M_t;
10 constexpr ~unique_ptr() {}
11 };
12 template <typename> struct _MakeUniq;
13 template <typename _Tp> struct _MakeUniq<_Tp[]> {
14 typedef unique_ptr<_Tp[]> __array;
15 };
16 template <typename _Tp> using __unique_ptr_array_t = _MakeUniq<_Tp>::__array;
17 constexpr __unique_ptr_array_t<char[]> make_unique(long __num) {
18 return unique_ptr<char[]>(new char[__num]);
19 }
20 } // namespace std
21 int a;
22 int
23 main ()
24 {
25 std::unique_ptr p = std::make_unique((long)&a);
26 constexpr std::unique_ptr p2 = std::make_unique((long)&a); // { dg-error "conversion" }
27 }