-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect codegen with returns inside nested ifs #890
Comments
The same issue happens with switch statements, where having a return inside an if causes a drop into the next case. public void OnPluginStart()
{
switch (0)
{
case 0:
{
if (0)
{
return;
}
PrintToServer("hi");
}
case 1:
{
if (0)
{
return;
}
PrintToServer("this should never happen");
}
default:
{
PrintToServer("this should never happen either");
}
}
}
Disassembly:
Without return statements it compiles fine. public void OnPluginStart()
{
switch (0)
{
case 0:
{
if (0)
{
// no return
}
PrintToServer("hi");
}
case 1:
{
if (0)
{
// no return
}
PrintToServer("this should never happen");
}
default:
{
PrintToServer("this should never happen either");
}
}
}
Disassembly:
This currently affects |
this bug is affecting my plugin. control is leaking and causing the plugin to malfunction. |
It should only affect the dev builds, not the stable builds. |
oh my bad, i could have sworn alliedmodders/sourcemod@cb85415 was merged into the 1.11 branch. either way, my plugin has started acting spuriously when built with the dev compiler so i've been using a pre- |
Thanks for the great test cases and analysis. This has been fixed on master. |
This snippet's control flow does not get compiled correctly, and both messages are printed when run.
Disassembly:
If the return statement inside the nested if is removed, it compiles properly and only the first message is printed.
Disassembly:
This issue started in SourceMod with alliedmodders/sourcemod@cb85415 and currently affects
basebans.sp::LoadBanReasons
, causing the plugin to always fail even if thebanreasons.txt
file exists.The text was updated successfully, but these errors were encountered: