Bug in DMD?

Vladimir Panteleev thecybershadow.lists at gmail.com
Fri Mar 3 02:04:03 UTC 2023


On Friday, 3 March 2023 at 01:21:52 UTC, ryuukk_ wrote:
> I have some questions:
>
> 1. why does it work with LDC?
> 2. why does it work with DMD when build/link in 2 step?
> 3. why it doesn't work when DMD is invoked once for build/link

I think these are probably coincidences and the answer can be 
summarized as "that's what ends up happening due to the details 
of the implementation".

> 4. is this a bug in DMD or my code is wrong?

I would say the code is wrong in principle, though as you've 
noted it can still work in some specific circumstances.

> 5. if it's wrong, then why does it compile/no error?

`extern(C) main` is a low-level feature, because it effectively 
turns off parts of the language. However, the rest of the program 
doesn't know that this is the case - currently the compiler 
simply assumes you know what you're doing. Maybe it's not OK that 
it's easy to use it by accident.



More information about the Digitalmars-d-learn mailing list