[Issue 21694] Misleading error message and invalid goto error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 18 20:12:47 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21694
--- Comment #2 from Răzvan Ștefănescu <rumbu at rumbu.ro> ---
The error message is not swallowed because the code is lowered in a 'try {goto}
finally', therefore there is no b declaration to jump over in the same scope as
goto after lowering.
If you replace the goto with a simple return, it is allowed. Skipping b
declaration is perfectly legit as long as b destructor is skipped, that's how
the return instruction will be lowered:
void test(int x)
{
A a = 0;
try
{
return;
}
finally
a.~this();
A b = 0;
b.~this();
}
The problem is that the original code is lowered to:
void test(int x)
{
A a = 0;
try
{
goto END;
}
finally
a.~this();
A b = 0;
END:
b.~this();
}
instead of the correct lowering:
void test(int x)
{
A a = 0;
try
{
goto END;
}
finally
a.~this();
A b = 0;
b.~this();
END:
}
By the way, the C++ compiler (MSVC) lowers the same code like this, which is
fine:
void test(int x)
{
{
A a = {};
~a;
goto END:
}
A b = {};
~b;
END:;
}
--
More information about the Digitalmars-d-bugs
mailing list