Which D compiler is the most maintained and future-proof? [DMD GDC and LDC]

Dennis dkorpel at gmail.com
Mon Jul 24 13:58:57 UTC 2023


On Monday, 24 July 2023 at 13:30:27 UTC, cc wrote:
> Is there any list of known significant "gotchas" with moving to 
> LDC from DMD?  Any unexpected surprises to watch out for or be 
> careful for?

- DMD has weak linking for all functions by default (mostly as a 
workaround to several bugs). In LDC, you might get 'duplicate 
definition' errors when linking D objects that succeeds when 
compiled with dmd.

- DMD supports C opaque struct definitions in headers (though 
arguably a bug as well) while LDC will complain, see 
https://github.com/ldc-developers/ldc/issues/3817

> Known edge cases of compiler optimization causing different 
> behavior between vendors?

LDC can optimize much more aggressively, so if your code has 
undefined behavior, it's more likely to manifest as a bug with 
LDC. I had a unittest that succeeded with dmd but failed with 
`ldc2 -O3` because there was a bitshift larger than 63. DMD 
didn't care much (it would just do modulo 64), but LDC optimized 
the function based on the assumption that a parameter could never 
be 0, which I didn't intend.


More information about the Digitalmars-d-learn mailing list