Bug 23584 – ImportC: __builtin_bit_cast not supported
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2022-12-27T20:18:34Z
Last change time
2023-01-09T19:02:58Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
Jacob Carlborg
Comments
Comment #0 by doob — 2022-12-27T20:18:34Z
Compiling the following C code:
int foo(float bar)
{
return __builtin_bit_cast(unsigned int, bar);
}
Results in the following errors:
foo.c(3): Error: expression expected, not `unsigned`
foo.c(3): Error: found `int` when expecting `)`
foo.c(3): Error: found `)` when expecting `;` following `return` statement
I'm using macOS 13.0.1, DMD v2.101.1 and Xcode 14.2.
Comment #1 by ibuclaw — 2022-12-27T23:15:03Z
Why do you expect DMD to implement GDC/GCC built-ins? (LDC might support them via Clang too, but is not guaranteed).
Comment #2 by doob — 2022-12-28T07:37:26Z
I'm just trying to compile a C project and reporting compile errors as they appear.
The module __builtins.di already contains subs or implementations of a couple of __builtins. Since it's not possible to pass types to regular functions a macro needs to be added to importc.h that rewrites it to something that DMD can handle. I added the following to importc.h:
#define __builtin_bit_cast(type,expr) (type) expr
And then could at least continue compiling until the next error.
Comment #3 by bugzilla — 2023-01-09T09:13:30Z
Jacob, yes please on posting everything you run into.
Comment #4 by dlang-bot — 2023-01-09T09:33:26Z
@WalterBright created dlang/dmd pull request #14795 "fix Issue 23584 - ImportC: __builtin_bit_cast not supported" fixing this issue:
- fix Issue 23584 - ImportC: __builtin_bit_cast not supported
https://github.com/dlang/dmd/pull/14795
Comment #5 by dlang-bot — 2023-01-09T19:02:58Z
dlang/dmd pull request #14795 "fix Issue 23584 - ImportC: __builtin_bit_cast not supported" was merged into master:
- 9ffb041d07cc5b3b47a803a18d1b7b31a6e79d6b by Walter Bright:
fix Issue 23584 - ImportC: __builtin_bit_cast not supported
https://github.com/dlang/dmd/pull/14795