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).