fix Issue 23584 - ImportC: __builtin_bit_cast not supported (#14795)

This commit is contained in:
Walter Bright 2023-01-09 11:02:49 -08:00 committed by GitHub
parent 3368127d1a
commit ee1acbb62d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -13,3 +13,17 @@ struct Foo {
int y = ((size_t)((char *)&((struct Foo *)1)->x - (char *)1));
_Static_assert(((size_t)((char *)&((struct Foo *)0)->y - (char *)0))==4, "");
// https://issues.dlang.org/show_bug.cgi?id=23584
int foo(float bar)
{
return __builtin_bit_cast(unsigned int, bar);
}
void test23584()
{
int i = foo(3.5);
_Static_assert(foo(3.5) == 0x40600000, "1");
}

View file

@ -71,6 +71,8 @@
*/
#define __builtin_offsetof(t,i) ((typeof(sizeof(0)))((char *)&((t *)0)->i - (char *)0))
#define __builtin_bit_cast(t,e) (*(t*)(void*)&(e))
/***************************
* C11 6.10.8.3 Conditional feature macros
*/