File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,24 @@ template <class To, class From>
3131constexpr To bit_cast (const From &from) {
3232 static_assert (sizeof (To) == sizeof (From));
3333 return __builtin_bit_cast (To, from); // ref-note 2{{indeterminate value can only initialize}} \
34- // expected-note 2{{indeterminate value can only initialize}}
34+ // expected-note 2{{indeterminate value can only initialize}} \
35+ // ref-note {{subexpression not valid}}
3536}
3637
38+
39+ // / Current interpreter does not support this.
40+ // / https://github.com/llvm/llvm-project/issues/63686
41+ constexpr int FromString = bit_cast<int >(" abc" ); // ref-error {{must be initialized by a constant expression}} \
42+ // ref-note {{in call to}} \
43+ // ref-note {{declared here}}
44+ #if LITTLE_END
45+ static_assert (FromString == 6513249 ); // ref-error {{is not an integral constant expression}} \
46+ // ref-note {{initializer of 'FromString' is not a constant expression}}
47+ #else
48+ static_assert (FromString == 1633837824 ); // ref-error {{is not an integral constant expression}} \
49+ // ref-note {{initializer of 'FromString' is not a constant expression}}
50+ #endif
51+
3752template <class Intermediate , class Init >
3853constexpr bool round_trip (const Init &init) {
3954 return bit_cast<Init>(bit_cast<Intermediate>(init)) == init;
You can’t perform that action at this time.
0 commit comments