digitalmars.D.bugs - [Issue 24351] New: Cannot format `void[]` at compile time
- d-bugmail puremagic.com (27/27) Jan 22 https://issues.dlang.org/show_bug.cgi?id=24351
https://issues.dlang.org/show_bug.cgi?id=24351 Issue ID: 24351 Summary: Cannot format `void[]` at compile time Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: ogion.art gmail.com This affects all functions that use `formattedWrite`: `format`, `sformat`, `writef`, `writefln` etc. ``` import std.format : format; int[] arr = [1, 2, 3, 4]; auto s1 = format("%s", cast(void[])arr); // Works auto s2 = format!"%s"(cast(void[])arr); /* Error: array cast from `void[]` to `const(ubyte[])` is not supported at compile time */ ``` Compile time `formattedWrite` validates the format string by trying to call a regular `formattedWrite` with dummy arguments at compile time. This fails because `void[]` is formatted by casting it to `const(ubyte[]), and casts are not allowed at compile time. --
Jan 22