We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7d78fcc + 1249899 commit 726e152Copy full SHA for 726e152
include/swift/Basic/Casting.h
@@ -41,9 +41,17 @@ Destination function_cast(Source source) {
41
static_assert(std::is_trivially_copyable_v<Destination>,
42
"The destination type must be trivially constructible");
43
44
+#if __has_feature(ptrauth_calls)
45
+ // Use reinterpret_cast here so we perform any necessary auth-and-sign.
46
+#pragma clang diagnostic push
47
+#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
48
+ return reinterpret_cast<Destination>(source);
49
+#pragma clang diagnostic pop
50
+#else
51
Destination destination;
52
memcpy(&destination, &source, sizeof(source));
53
return destination;
54
+#endif
55
}
56
57
0 commit comments