www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24110] New: [REG2.104] Array comparison lowering apparently

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

          Issue ID: 24110
           Summary: [REG2.104] Array comparison lowering apparently not
                    handled properly in __traits(compiles)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kinke gmx.net

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
```

--
Aug 25 2023