GCC builtins in LDC - compiler interoperability
noone at nowhere.com
Thu Jul 16 00:06:49 UTC 2020
On Wednesday, 15 July 2020 at 23:31:39 UTC, Cecil Ward wrote:
> Oh, shame. There’s no __builtin_unreachable in ldc? I wonder if
> I could work around this with LDC then.
With D / LDC, there's almost always a workaround. In this case,
using inline LLVM IR (as 'unreachable' is an IR instruction for
bool foo() nothrow;
// due to a current LDC bug, a dummy parameter is required
__ir!(`unreachable`, void, int)(0);
int r = 123;
r = 456;
With -O, bar() is optimized to a `return 123`.
More information about the digitalmars-d-ldc