[Issue 23722] Lambdas are mangled incorrectly when using multiple compilation units, resulting in incorrect code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 20 15:40:24 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=23722

--- Comment #8 from kinke <kinke at gmx.net> ---
(In reply to ilya.yanok from comment #7)
> (In reply to kinke from comment #6)
> > Yes, I fixed the first issue (different lambdas getting the same mangle and
> > incorrectly being folded at link-time) in LDC v1.33:
> > https://github.com/ldc-developers/ldc/pull/4415
> 
> Cool! But that won't help with lambda names leaking into template
> instantiations' symbol via arguments unfortunately. So I think we really
> need lambda names to be stable (which the PR does).

Oh right, that's a remaining problem indeed.

> I was actually curious about the second issue: LDC seems to generate the
> code for
> 
> alias f = () { ... }
> 
> for all modules that use `f`, while dmd only generates it if a module that
> uses `f` is compiled together with the module that defines it (or if that's
> the same module). Do you happen to know where does this difference come from?

Different code emission strategies in the glue layer, here for lambdas. There
are also significant emission strategy differences for non-class TypeInfos
across DMD and LDC. I prefer defining these symbols on a lazy basis in each
referencing object file, for robustness and inline-ability (without needing
LTO).

--


More information about the Digitalmars-d-bugs mailing list