Bug 24110 – [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles)

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-08-25T20:38:14Z
Last change time
2023-09-16T07:31:17Z
Keywords
pull
Assigned to
No Owner
Creator
kinke

Comments

Comment #0 by kinke — 2023-08-25T20:38:14Z
The compiler states it can compile something which actually fails to compile: ``` struct S { int x; } alias T = shared S; static assert(__traits(compiles, (T[] a, T[] b) => a < b)); // newly succeeds since v2.104 bool foo(T[] a, T[] b) { return a < b; } // fails with v2.104 and v2.105 ``` The error with DMD v2.105.0 is: ``` core/internal/array/comparison.d(126): Error: function `core.stdc.string.memcmp(scope const(void*) s1, scope const(void*) s2, ulong n)` is not callable using argument types `(shared(S)*, shared(S)*, ulong)` core/internal/array/comparison.d(126): cannot pass argument `&at(s1, u)` of type `shared(S)*` to parameter `scope const(void*) s1` foo.d(4): Error: template instance `core.internal.array.comparison.__cmp!(shared(S), shared(S))` error instantiating ```
Comment #1 by kinke — 2023-08-25T20:42:28Z
FWIW, a similar inconsistency with a floating-point `opCmp` result of the array elements (the same v2.104 regression wrt. `__traits(compiles)`) was fixed in D v2.105 by fixing the array comparison; see https://github.com/ldc-developers/ldc/pull/4475 for details.
Comment #2 by dlang-bot — 2023-09-05T13:16:51Z
@RazvanN7 created dlang/dmd pull request #15575 "Fix Issue 24110 - [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles)" fixing this issue: - Fix Issue 24110 - [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles) https://github.com/dlang/dmd/pull/15575
Comment #3 by dlang-bot — 2023-09-05T13:46:14Z
@RazvanN7 created dlang/dmd pull request #15576 "Fix Issue 24110 - [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles) " fixing this issue: - Fix Issue 24110 - [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles) https://github.com/dlang/dmd/pull/15576
Comment #4 by dlang-bot — 2023-09-07T11:52:25Z
dlang/dmd pull request #15575 "Fix Issue 24110 - [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles)" was merged into stable: - 7a10bd62ea695c8f53336dcd3393b9fc1432e5e3 by RazvanN7: Fix Issue 24110 - [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles) https://github.com/dlang/dmd/pull/15575
Comment #5 by dlang-bot — 2023-09-16T07:31:17Z
dlang/dmd pull request #15609 "merge stable" was merged into master: - c9d1581f5505547fd70865ec145f915176dac022 by Razvan Nitu: Fix Issue 24110 - [REG2.104] Array comparison lowering apparently not handled properly in __traits(compiles) (#15575) https://github.com/dlang/dmd/pull/15609