Bug 23754 – betterC cannot use std.format at compile time

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-03-01T02:30:50Z
Last change time
2024-12-13T19:27:32Z
Keywords
betterC
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=18472
Moved to GitHub: dmd#20240 →

Comments

Comment #0 by bugzilla — 2023-03-01T02:30:50Z
The following still does not work: --- import std.format; import std.stdio; void main() { enum s = "%1$s,%2$s".format("foo","bar"); writeln(s); } --- now failing with the message: std/array.d(3418): Error: `TypeInfo` cannot be used with -betterC The previous report on this, https://issues.dlang.org/show_bug.cgi?id=18472, found a compiler bug preventing it from working, but that bug was fixed. The problem now appears to be that `format` does not have an `if(__ctfe)` path in it.
Comment #1 by bugzilla — 2023-03-01T02:45:07Z
On second thought, it's still another compiler problem. CTFE should still be on when compiling format.
Comment #2 by bugzilla — 2023-03-11T19:26:37Z
The problem is illustrated with: --- void test() { enum s = foo(); } int foo() { new C(); return 1; } class C { } --- While executing foo() at compile time works, even with -betterC, the compiler still tries to generate code for foo(). This produces the error about a reference to TypeInfo.
Comment #3 by robert.schadek — 2024-12-13T19:27:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20240 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB