You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
The following is a script that will demonstrate the problem:
//////////////////////////////////////////////
void demo_error()
{
int value = 5;
printf("Here's a print statement before quitting.\n");
if(1) {
printf("returning; there should be no further output.\n");
return;
}
printf("This statement should not print, and does not.\n");
switch(value)
{
case 5:
printf("case 5: value = %d\n", value);
break;
case 0:
printf("case 0: value=%d\n", value);
break;
}
printf("This statement also should not and does not print.\n");
return;
}
demo_error();
//////////////////////////////////////////////
Notice that from this simple script the execution is well defined; there should
be exactly two printf's called followed by a return from the function.
With that script in a file "demo_error.c", the command "./picoc -s
demo_error.c" will run it.
What is the expected output? What do you see instead?
Expected output:
Here's a print statement before quitting.
returning; there should be no further output.
Actual output:
Here's a print statement before quitting.
returning; there should be no further output.
case 0: value=5
Rather than returning from the if block, the return statement is jumping into
the case 0 switch block, as evidenced by which printf's do and do not run.
Changing the order of cases in the switch block have no effect; the case 0
printf is still executed.
Changing the value of "value" also has no effect.
What version of the product are you using? On what operating system?
I've reproduced this problem using version 603, on Linux and OS X.
Original issue reported on code.google.com by m...@heilpern.com on 27 Feb 2014 at 5:17
The text was updated successfully, but these errors were encountered:
I think the bug is somewhere in the function ParseStatement() in the processing
of a switch token.
I found a fix, not sure if is the correct way to do by replacing line 809:
ParseBlock(Parser, TRUE, OldMode != RunModeSkip);
by:
ParseBlock(Parser, TRUE, (OldMode != RunModeSkip) && (OldMode !=
RunModeReturn));
Original comment by christop...@gmail.com on 28 Feb 2014 at 2:20
Original issue reported on code.google.com by
m...@heilpern.com
on 27 Feb 2014 at 5:17The text was updated successfully, but these errors were encountered: