[Issue 21109] Possibly wrong codegen when using enum arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 4 04:33:30 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21109
--- Comment #4 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
(In reply to Andrej Mitrovic from comment #3)
> I think this is related to `sort`. It's possible that sort compares by
> pointers if two structs are otherwise equivalent.
>
> And then using `enum` has a different effect on arrays, possibly optimizing
> and storing the same pointer in two structs (making them equal).
Sorry the actual reasoning should be: `enum` always allocates a new array,
therefore the pointer addresses change each time.
It's possible opCmp does a value comparison first, and then a pointer
comparison.
But I don't think pointers should be compared at all.. at least not when
dealing with arrays and not naked pointers in a struct.
--
More information about the Digitalmars-d-bugs
mailing list