@@ -35,6 +35,15 @@ static_assert(UBitIntZero1 == 0, "");
35
35
constexpr unsigned _BitInt (2 ) BI1 = 3u;
36
36
static_assert (BI1 == 3 , " " );
37
37
38
+ constexpr _BitInt (4 ) MulA = 5;
39
+ constexpr _BitInt (4 ) MulB = 7;
40
+ static_assert (MulA * MulB == 50 , " " ); // ref-error {{not an integral constant expression}} \
41
+ // ref-note {{value 35 is outside the range of representable values of type '_BitInt(4)'}} \
42
+ // expected-error {{not an integral constant expression}} \
43
+ // expected-note {{value 35 is outside the range of representable values of type '_BitInt(4)'}}
44
+ static_assert (MulA * 5 == 25 , " " );
45
+ static_assert (-1 * MulB == -7 , " " );
46
+
38
47
namespace APCast {
39
48
constexpr _BitInt (10 ) A = 1;
40
49
constexpr _BitInt (11 ) B = A;
@@ -66,13 +75,20 @@ namespace i128 {
66
75
// ref-error {{static assertion failed}} \
67
76
// ref-note {{'340282366920938463463374607431768211455 == 1'}}
68
77
78
+ constexpr uint128_t TooMuch = UINT128_MAX * 2 ;
79
+
69
80
static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t )1 ;
70
81
static_assert (INT128_MAX != 0 , " " );
71
82
static_assert (INT128_MAX == 0 , " " ); // expected-error {{failed}} \
72
83
// expected-note {{evaluates to '170141183460469231731687303715884105727 == 0'}} \
73
84
// ref-error {{failed}} \
74
85
// ref-note {{evaluates to '170141183460469231731687303715884105727 == 0'}}
75
86
87
+ constexpr int128_t TooMuch2 = INT128_MAX * INT128_MAX; // ref-error {{must be initialized by a constant expression}} \
88
+ // ref-note {{value 28948022309329048855892746252171976962977213799489202546401021394546514198529 is outside the range of representable}} \
89
+ // expected-error {{must be initialized by a constant expression}} \
90
+ // expected-note {{value 28948022309329048855892746252171976962977213799489202546401021394546514198529 is outside the range of representable}}
91
+
76
92
static const __int128_t INT128_MIN = -INT128_MAX - 1 ;
77
93
constexpr __int128 A = INT128_MAX + 1 ; // expected-error {{must be initialized by a constant expression}} \
78
94
// expected-note {{value 170141183460469231731687303715884105728 is outside the range}} \
0 commit comments