Bug 22082 – static float array comparison not available in betterC

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-24T14:32:53Z
Last change time
2024-12-13T19:17:20Z
Keywords
betterC, pull
Assigned to
No Owner
Creator
Dennis
Moved to GitHub: dmd#19954 →

Comments

Comment #0 by dkorpel — 2021-06-24T14:32:53Z
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 } ```
Comment #1 by ryuukk.dev — 2021-09-13T23:50:17Z
I tried the workaround but it didn't work for me https://bpa.st/raw/MVJQ
Comment #2 by ryuukk.dev — 2021-09-14T00:19:56Z
``` 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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19954 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB