Debian Codegraph @

gcc/testsuite/g++.dg/init/new38.C

raw
1 // { dg-do compile }
2
3 void
4 large_array_char(int n)
5 {
6 new char[n]
7 [1ULL << (sizeof(void *) * 4)]
8 [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of array" }
9 }
10
11 template <typename T>
12 void
13 large_array_char_template(int n)
14 {
15 new char[n]
16 [1ULL << (sizeof(void *) * 4)]
17 [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of array" }
18 }
19
20
21 template <typename T>
22 void
23 large_array_template1(int n)
24 {
25 new T[n] // { dg-error "size of array exceeds maximum object size" }
26 [(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
27 [1ULL << (sizeof(void *) * 4)];
28 }
29
30 template <typename T>
31 void
32 large_array_template2(int n)
33 {
34 new T[n] // { dg-error "size of array exceeds maximum object size" }
35 [(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
36 [1ULL << (sizeof(void *) * 4)];
37 }
38
39 template <typename T>
40 void
41 large_array_template3(int n)
42 {
43 new T[n] // { dg-error "size.*of array exceeds maximum object size" }
44 [(1ULL << (sizeof(void *) * 4)) / sizeof(T)]
45 [1ULL << (sizeof(void *) * 4)];
46 }
47
48 void
49 call_large_array_template(int n)
50 {
51 large_array_template1<char>(n);
52 large_array_template2<int>(n);
53 large_array_template3<double>(n);
54 }