[Issue 19268] BetterC turns off DRuntime for CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 26 23:17:20 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=19268
--- Comment #12 from Adam D. Ruppe <destructionator at gmail.com> ---
(In reply to Steven Schveighoffer from comment #9)
> Except this is not the problem. The CTFE part DOES compile.
eeeeh, it is the problem that brought me to this bug.
private string makefoo() {
if(__ctfe) {
string a = "b";
a ~= "c\0";
return a;
}
assert(0);
}
enum foo = makefoo();
extern(C) int main() {
import core.stdc.stdio;
printf("%s", foo.ptr);
return 0;
}
Here that private function is obviously intended to be CTFE only - the
`private` and `if(__ctfe)` make that extremely clear to a human reader, but the
compiler doesn't get the hint.
We could also do a like `pragma(ct_only)` maybe just I was hoping this pattern
would work since it is in the existing language. But nope :(
--
More information about the Digitalmars-d-bugs
mailing list