[Issue 19268] BetterC turns off DRuntime for CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 26 21:02:05 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=19268

--- Comment #8 from Adam D. Ruppe <destructionator at gmail.com> ---
My view is that the code compiles just fine. Just without druntime linked in or
generated typeinfo, or whatever it depends on at run time, it will not link.

The -betterC switch tries to detect these these would-be linker errors and
report them ahead of time, in the compile step, for more consistent and
user-friendly errors.

Since an `if(__ctfe)` branch (or `mixin` or `pragma(msg)` or any other
unambiguously* compile-time only area) is never actually involved in code
generation, that linker error will never actually happen... and the compiler
*should* know that and not cause the ahead-of-time compile error eiter.

* __traits(compiles) (and is(typeof())) is a grey area. Technically it isn't
generating code at all and thus should not generate a linker error, and thus
not generate the betterC error.... but given how it is used in practice I think
it should assume the stuff inside WILL be used for codegen and thus return
false in these cases.

But when in doubt, I say `-betterC` should aim to give the same end result as
`-defaultlib=` just with compile errors instead of linker undefined symbol
errors.

--


More information about the Digitalmars-d-bugs mailing list