Bug 24182 – DMD crashes when compile time sort is called with templatized opCmp()

Status
NEW
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-10-09T18:19:26Z
Last change time
2024-12-13T19:31:04Z
Assigned to
No Owner
Creator
Puneet Goel
Moved to GitHub: dmd#20338 →

Comments

Comment #0 by puneet — 2023-10-09T18:19:26Z
$ dmd -c foo.d invalid op 32 94 Illegal instruction (core dumped) The error goes away if I comment out either of F0, F1..5 The error also goes away if I use a non-templatized version of opCmp -- as in int opCmp(bar other) // foo.d enum foo { // No error if one of these is commented out F0 = bar(0), F1 = bar(1), F2 = bar(2), F3 = bar(3), F4 = bar(4), F5 = bar(5) } struct bar { int _val; this(int val) { _val = val; } int opCmp(U)(U other) { if (_val == other._val) return 0; if (_val > other._val) return 1; else return -1; } } struct frop(T) { enum _elems = getSortedMembers!T; static T[] getSortedMembers(T)() { import std; return array([EnumMembers!T].sort()); } } alias fropfoo = frop!foo;
Comment #1 by robert.schadek — 2024-12-13T19:31:04Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20338 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB