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.
  • Which D compiler... BoQsc via Digitalmars-d-learn
    • Re: Which D... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Whi... devosalain via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Whi... cc via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... Steven Schveighoffer via Digitalmars-d-learn
          • ... Johan via Digitalmars-d-learn
        • Re:... Dennis via Digitalmars-d-learn
        • Re:... IchorDev via Digitalmars-d-learn
    • Re: Which D... Guillaume Piolat via Digitalmars-d-learn

Reply via email to