Bug 24222 – emplace uses wrong init value for enum

Status
NEW
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-11-03T00:55:55Z
Last change time
2024-12-07T13:42:58Z
Assigned to
No Owner
Creator
Paul Backus
Moved to GitHub: dmd#17210 →

Comments

Comment #0 by snarwin+bugzilla — 2023-11-03T00:55:55Z
As of DMD 2.105.3, the following program asserts at runtime: --- import core.lifetime; enum E : int[5] { a = [1, 2, 3, 4, 5] } void main() { E e = void; emplace(&e); assert(e == E.init); } --- The message, with -checkaction=context, is --- [email protected](9): cast(E) [0, 0, 0, 0, 0] != a --- This happens because core.lifetime.emplace uses the .init value of the enum's base type, int, to initialize `e`, rather than the .init value of the enum itself.
Comment #1 by robert.schadek — 2024-12-07T13:42:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17210 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB