Bug 24351 – Cannot format `void[]` with compile-time check

Status
NEW
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-22T08:04:54Z
Last change time
2024-12-01T16:42:15Z
Assigned to
No Owner
Creator
Georgy Markov
Moved to GitHub: phobos#10543 →

Comments

Comment #0 by ogion.art — 2024-01-22T08:04:54Z
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.
Comment #1 by ogion.art — 2024-01-22T08:55:44Z
Comment #2 by robert.schadek — 2024-12-01T16:42:15Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10543 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB