Created
July 23, 2011 06:20
-
-
Save chadbrewbaker/1101098 to your computer and use it in GitHub Desktop.
Bug in GCC goto parsing or the C99 standard?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define N 100 | |
| int perm[N]; | |
| void gcc_goto_issue(){ | |
| int i,start, current; | |
| for(i=0;i<N;i++){ | |
| start = perm[i]; | |
| current = perm[start]; | |
| long counter = 0; | |
| while(start != current){ | |
| if(current < start) goto loopEnd; | |
| current = perm[current]; | |
| } | |
| // Do something here with this permutation cycle | |
| // as we haven't seen it yet. | |
| loopEnd: | |
| // When using i686-apple-darwin10-gcc-4.2.1 | |
| // the compiler gives an error unless I uncomment the next line. | |
| //i=i; | |
| } | |
| } | |
| int main () { | |
| int i; | |
| for(i=0;i<N;i++) | |
| perm[i]= i; //Input is a random permutation | |
| gcc_goto_issue(); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you put a single ";" after the goto label it compiles fine.