final switch problem

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Jun 13 22:48:10 UTC 2020


On Saturday, June 13, 2020 10:22:39 AM MDT John Chapman via Digitalmars-d-
learn wrote:
> On Saturday, 13 June 2020 at 15:33:55 UTC, Boris Carvajal wrote:
> > On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote:
> >> Is this a bug or have I made a mistake? This worked a few days
> >> ago and I haven't changed my setup since then.
> >
> > https://issues.dlang.org/show_bug.cgi?id=19548
> >
> > Your code triggers it by using "-debug" option on
> > https://run.dlang.io/ using DMD
>
> Hmm, compiling with -release makes it work. Not a huge issue,
> I'll just avoid final switches in debug mode until it's fixed.
> Thanks.

Just be aware that that removes the code that gets generated which throws a
SwitchError if the wrong value is passed to the final switch. So, instead of
getting a SwitchError thrown, you'll get who-knows-what weird behavior
happening if you have a bug with what you pass to the the switch (and of
course, you lose assertions in general). It does sound like the problem
that's resulting in the compilation error relates to the invisible default
case that gets generated without -release though.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list