On Monday, 28 April 2025 at 22:51:17 UTC, An Pham wrote:
> ...
Very interesting. I don't crash the compiler itself (dmd 2.111.0, ArchLinux), but the program crashes at runtime.
Output:
T=float
v=4, tsa=[4], sizeof=4
T=double
v=8, tsa=[8], sizeof=8
T=real
(...series of unreadable characters...)
std.exception.ErrnoException@/usr/include/dlang/dmd/std/stdio.d(3124): Enforcement failed (Bad address)
----------------
??:? @safe noreturn std.exception.bailOut!(std.exception.ErrnoException).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x5f49e374c7fa]
??:? @safe int std.exception.enforce!(std.exception.ErrnoException).enforce!(int).enforce(int, lazy const(char)[], immutable(char)[], ulong) [0x5f49e374c780]
??:? @safe void std.stdio.File.LockingTextWriter.put!(immutable(char)[]).put(scope immutable(char)[]) [0x5f49e374c697]
??:? @safe void std.range.primitives.doPut!(std.stdio.File.LockingTextWriter, immutable(char)[]).doPut(ref std.stdio.File.LockingTextWriter, ref immutable(char)[]) [0x5f49e374bdcb]
??:? @safe void std.range.primitives.put!(std.stdio.File.LockingTextWriter, immutable(char)[]).put(ref std.stdio.File.LockingTextWriter, immutable(char)[]) [0x5f49e374bdab]
??:? @safe void std.stdio.File.write!(immutable(char)[], real, immutable(char)[], real[1], immutable(char)[], ulong, char).write(immutable(char)[], real, immutable(char)[], real[1], immutable(char)[], ulong, char) [0x5f49e3775906]
??:? @safe void std.stdio.writeln!(immutable(char)[], real, immutable(char)[], real[1], immutable(char)[], ulong).writeln(immutable(char)[], real, immutable(char)[], real[1], immutable(char)[], ulong) [0x5f49e377585f]
??:? _Dmain [0x5f49e374bae3]
Everything works fine with the ldc2 and gdc compilers (I haven't checked the newest versions).
Output:
T=float
v=4, tsa=[4], sizeof=4
T=double
v=8, tsa=[8], sizeof=8
T=real
v=16, tsa=[16], sizeof=16
In any case, write a bug report.