1 // RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -triple x86_64-apple-macosx10.14.0 %s
2 // RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -triple x86_64-apple-macosx10.14.0 %s -fno-signed-char
4 #if !__has_builtin(__builtin_bit_cast)
8 template <class T
, T v
>
10 return __builtin_bit_cast(T
, v
);
13 int x
= instantiate
<int, 32>();
18 private: secret_ctor() = default;
22 secret_ctor c
= __builtin_bit_cast(secret_ctor
, (char)0);
27 // expected-error@+1{{size of '__builtin_bit_cast' source type 'const int' does not match destination type 'char' (4 vs 1 bytes)}}
28 constexpr char c
= __builtin_bit_cast(char, i
);
31 struct not_trivially_copyable
{
35 // expected-error@+1{{'__builtin_bit_cast' source type must be trivially copyable}}
36 constexpr unsigned long ul
= __builtin_bit_cast(unsigned long, not_trivially_copyable
{});
38 // expected-error@+1 {{'__builtin_bit_cast' destination type must be trivially copyable}}
39 constexpr long us
= __builtin_bit_cast(unsigned long &, 0L);
42 template <class T
> struct S
{ int m
; };
44 extern S
<int> extern_decl
;
46 int x
= __builtin_bit_cast(int, extern_decl
);
47 S
<char> y
= __builtin_bit_cast(S
<char>, 0);