Bug 21071 – Undefined reference error when converting strings to enums in static switch.

Status
RESOLVED
Resolution
WORKSFORME
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-07-24T23:06:34Z
Last change time
2020-08-21T23:43:56Z
Keywords
link-failure
Assigned to
No Owner
Creator
Vaptistis Anogeianakis
See also
https://issues.dlang.org/show_bug.cgi?id=19548

Comments

Comment #0 by nomad — 2020-07-24T23:06:34Z
When I try to convert a string to an enumeration using "to!MyEnum" inside the switch header, I'm getting an undefined reference error from the linker when I attempt to compile in debug mode with dmd. Suppose I have a `main.d` file like the following: import std.string /*required to reproduce error*/, std.conv; void main() { enum Foo {bar} // Just `to!Foo` or just `final switch` aren't // enough to reproduce the error final switch(to!Foo("bar")) { case Foo.bar: } } and I attempt to compile using `dmd -debug main.d`. I'd expect compilation to finish successfully, but instead I'm getting: main.o: In function `_Dmain': main.d:(.text._Dmain[_Dmain]+0x2e): undefined reference to `_D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv' collect2: error: ld returned 1 exit status Error: linker exited with status 1 I have confirmed I'm getting this error with dmd v2.092.0 but not with dmd version v2.091.0. Thus a regression. Known workarounds include: - Omitting the `-debug` flag. - Using the `-release` flag. - Including the `-allinst` flag. - Including the `-checkaction=C` flag. I'm running Linux Mint 18 Sarah, but I've also been able to reproduce this in a docker container based on Ubuntu Bionic Beaver (https://github.com/avnomad/dop-parser/blob/default/dockerfile).
Comment #1 by b2.temp — 2020-08-21T23:43:56Z
fixed since v2.093