================
@@ -111,3 +111,12 @@ namespace non_trivially_copyable {
_Atomic S s; // expected-error {{_Atomic cannot be applied to type 'S'
which is not trivially copyable}} \
// expected-warning {{'_Atomic' is a C11 extension}}
}
+
+namespace static_cast_crash {
+ struct S { char a; };
+ void static_cast_non_atomic_to_atomic() {
+ _Atomic struct S a; // expected-warning {{'_Atomic' is a C11 extension}}
+ a = static_cast<_Atomic(struct S)>(S()); // expected-warning {{'_Atomic'
is a C11 extension}}
----------------
AaronBallman wrote:
Another interesting test case:
```
struct S {
operator float() const;
int a;
};
struct T {
operator _Atomic(S)() const;
};
void static_cast_non_atomic_to_atomic() {
_Atomic struct S s;
s = static_cast<_Atomic(S)>(T{});
}
```
This fails today but should succeed with your patch. But then there's the
sadder test case:
```
struct S {
operator float() const;
int a;
};
struct T {
operator _Atomic(S)() const;
};
void static_cast_non_atomic_to_atomic() {
float f;
f = static_cast<float>(static_cast<_Atomic(S)>(T{}));
}
```
This *won't* work because the atomic is not being stripped from the cast and
you cannot access members of an atomic object (so no way to call the conversion
operator).
https://github.com/llvm/llvm-project/pull/207616
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits