Applying a UDA to a File-type variable makes DMD crash
Marcos Cruz
d-forum at programandala.net
Sat Dec 20 12:58:50 UTC 2025
Hi, all.
I have been learning and using D for several months, and following the
forum groups by email. In fact D has become my language of choice.
Some weeks ago I found a strange issue. The following code makes DMD
(2.111.0) crash with message "terminated by signal SIGSEGV (Address
boundary error)", while LDC (1.41.0) and GDC (14.2.0) compile it (I use
Debian 13.2, x86_64):
```D
enum var;
import std.stdio : File;
@var File file = File("tmp", "w");
```
The same problem happens with OpenD: `opend dmd` throws "dmd killed by
signal 11", while `opend ldc2` compiles fine.
The workaround I found is to separate the assignment from the
declaration; then DMD compiles the code:
```D
enum var;
import std.stdio : File;
@var File file;
file = File("tmp", "w");
```
I have found no problem applying UDAs to variables of other types,
including structs.
I have tried also RDMD: it crashes silently, i.e. the code fails at the
same point but no system error message is displayed:
```
rdmd --eval 'enum var; @var File file = File("/tmp/x", "w"); write("NEVER REACHED")'
```
As before, it works when the assignment is separated from the declaration:
```
rdmd --eval 'enum var; @var File file; file = File("/tmp/x", "w"); write("OK");'
```
I have searched the DMD's issues on GitHub but found nothing related.
Am I missing something or is it a bug?
--
Marcos Cruz
More information about the Digitalmars-d
mailing list