foralex / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Break statement not working correctly #163

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 dplak...@gmail.com on 16 Aug 2012 at 1:33

GoogleCodeExporter commented 8 years ago
Thanks for the bug report - I'll look into it soon.

Original comment by zik.sale...@gmail.com on 15 Sep 2012 at 2:45

GoogleCodeExporter commented 8 years ago
Here's a possible fix.

Original comment by broscuta...@gmail.com on 5 Mar 2013 at 7:17

Attachments:

GoogleCodeExporter commented 8 years ago
Related bug for "continue".

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

Original comment by broscuta...@gmail.com on 6 Mar 2013 at 10:01

GoogleCodeExporter commented 8 years ago
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 broscuta...@gmail.com on 6 Mar 2013 at 10:31

GoogleCodeExporter commented 8 years ago
Patch applied - many thanks.

Original comment by zik.sale...@gmail.com on 16 Mar 2013 at 6:06