Skip to content
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

Break statement not working correctly #163

Closed
GoogleCodeExporter opened this issue Oct 14, 2015 · 5 comments
Closed

Break statement not working correctly #163

GoogleCodeExporter opened this issue Oct 14, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Run this

#include <stdio.h>
int main()
{
 int a,c;
 a = 0;
 while (1)
  {
    printf("%d", a++);
    break;
    for (c=0;c<10;c++)printf("c=%d\n",c);
  }
    return 0;
}   

What is the expected output? 0 What do you see instead? countinous output of 
012345678910111213141516171819.........


What version of the product are you using? 2.1 On what operating system? WIN32


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 16 Aug 2012 at 1:33

@GoogleCodeExporter
Copy link
Author

Thanks for the bug report - I'll look into it soon.

Original comment by [email protected] on 15 Sep 2012 at 2:45

  • Changed state: Accepted
  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

Here's a possible fix.

Original comment by [email protected] on 5 Mar 2013 at 7:17

Attachments:

@GoogleCodeExporter
Copy link
Author

Related bug for "continue".

- Source: http:https://www.go-hero.net/jam/11/name/eduardische , Round 2, Expensive 
Dinner, small
- Input: C-small from 
http:https://code.google.com/codejam/contest/1150486/dashboard#s=p2
- bug: case #26 is printed twice (gcc prints it once)

Original comment by [email protected] on 6 Mar 2013 at 10:01

@GoogleCodeExporter
Copy link
Author

Minimal example for the continue bug:

 printf("\nTest 4\n");

 a = 0; c = 0;
 for (c=0;c<10;c++)
 {
    printf("c=%d\n",c);
    foo();
    continue;
    for (a = 0; a < 2; a++)
        printf("a=%d\n",a);
    printf("bar\n");
 }

and possible fix:

        case TokenFor:
        {
            enum RunMode OldMode = Parser->Mode;
            ParseFor(Parser);
            Parser->Mode = OldMode;
            CheckTrailingSemicolon = FALSE;
            break;
        }

Original comment by [email protected] on 6 Mar 2013 at 10:31

@GoogleCodeExporter
Copy link
Author

Patch applied - many thanks.

Original comment by [email protected] on 16 Mar 2013 at 6:06

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant