Thread overview
[Issue 22427] betterC: casting an array causes linker error in string comparison.
Dec 17, 2022
Iain Buclaw
Jul 11, 2023
RazvanN
Jul 11, 2023
RazvanN
Jul 11, 2023
Dlang Bot
Jul 14, 2023
Dlang Bot
October 19, 2021
https://issues.dlang.org/show_bug.cgi?id=22427

dave287091@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |betterC, link-failure

--
October 19, 2021
https://issues.dlang.org/show_bug.cgi?id=22427

--- Comment #1 from dave287091@gmail.com ---
(In reply to dave287091 from comment #0)
> This reduced code fails to link.

I forgot to mention, compile with -betterC. Without -betterC it links fine.

--
October 19, 2021
https://issues.dlang.org/show_bug.cgi?id=22427

--- Comment #2 from dave287091@gmail.com ---
(In reply to dave287091 from comment #1)
> (In reply to dave287091 from comment #0)
> > This reduced code fails to link.
> 
> I forgot to mention, compile with -betterC. Without -betterC it links fine.

Also, without the array cast there it also links fine.

--
May 13, 2022
https://issues.dlang.org/show_bug.cgi?id=22427

--- Comment #3 from dave287091@gmail.com ---
This worked with dmd 2.093 and stopped working with dmd 2.094.

--
May 25, 2022
https://issues.dlang.org/show_bug.cgi?id=22427

--- Comment #4 from dave287091@gmail.com ---
The -allinst/--allinst flag will resolve the link error, but that is a counter-intuitive requirement as there is no explicit template in the program - just one injected by the compiler. The fact that array equality is implemented as a template is an implementation detail and shouldn’t require the user to work around it.

It’s also weird that the cast somehow changes whether the template is emitted.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22427

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
July 11, 2023
https://issues.dlang.org/show_bug.cgi?id=22427

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com
           Severity|major                       |regression

--
July 11, 2023
https://issues.dlang.org/show_bug.cgi?id=22427

--- Comment #5 from RazvanN <razvan.nitu1305@gmail.com> ---
It seems that the cast is lowered to __ArrayCast which in turn ends up instantiating __equals with the same template parameters, but in a speculative context (static if). Somehow, the template emission strategy decides that the instance does not require codegen (from what I can tell, the compiler decides that it's better to put the instance in the imported module - core.memory in this case), hence the linker errors.

I think that this strategy should be disabled in the case of betterC as it currently is with -allinst.

--
July 11, 2023
https://issues.dlang.org/show_bug.cgi?id=22427

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #15404 "Fix Issue 22427 - betterC: casting an array causes linker error in string comparison" fixing this issue:

- Fix Issue 22427 - betterC: casting an array causes linker error in string comparison

https://github.com/dlang/dmd/pull/15404

--
July 14, 2023
https://issues.dlang.org/show_bug.cgi?id=22427

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15404 "Fix Issue 22427 - betterC: casting an array causes linker error in string comparison" was merged into master:

- bab58df92fa67c4702bf001c8258ff2eeb4643bc by RazvanN7:
  Fix Issue 22427 - betterC: casting an array causes linker error in string
comparison

- 9e1ba7b233a73941ec094d60b226af92618301d8 by RazvanN7:
  Fix Issue 22427 - betterC: casting an array causes linker error in string
comparison

https://github.com/dlang/dmd/pull/15404

--