Array comparisons either:
- directly generate memcmp code (integral types) in e2ir.d
- call _adEq2 from druntime which uses TypeInfo
- are lowered to object.__equals in expressionsem.d
Comparing `float` arrays works in betterC through object.__equals, but when both arguments are static arrays, the lowering doesn't happen:
```
// compile with -betterC
void main() {
float[3] a, b;
const x = a[] == b; // fine
const y = a == b; // Error: `TypeInfo` cannot be used with -betterC
}
```
```
struct Test
{
float[32] data;
}
extern (C) int main()
{
Test b;
Test c;
bool r = b == c;
return 0;
}
```
A struct that contains a float array also doesn't work
Comment #3 by dlang-bot — 2021-11-19T03:05:47Z
@ryuukk created dlang/dmd pull request #13320 "Fix Issue 22082 - Static float array comparison now lowered to __equals" fixing this issue:
- Fix Issue 22082 - Static float array comparison now lowered to __equals
https://github.com/dlang/dmd/pull/13320
Comment #4 by bugzilla — 2023-01-15T07:53:45Z
The current error generated is:
Error: expression `a[] == cast(float[])b` uses the GC and cannot be used with switch `-betterC`
Comment #5 by robert.schadek — 2024-12-13T19:17:20Z