diff --git a/compiler/test/compilable/test22809.c b/compiler/test/compilable/test22809.c index 1f41da0dad..68752d50a0 100644 --- a/compiler/test/compilable/test22809.c +++ b/compiler/test/compilable/test22809.c @@ -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"); +} diff --git a/druntime/src/importc.h b/druntime/src/importc.h index bcdfb8b5f2..d54ca1b1d6 100644 --- a/druntime/src/importc.h +++ b/druntime/src/importc.h @@ -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 */