[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    problem with -fshort-enums in egcs-1.1.1
From:       Charles G Waldman <cgw () alum ! mit ! edu>
Date:       1999-01-31 0:14:50
[Download RAW message or body]


Please cc: me on any replies to this as I am not subscribed to this
list.

I found a problem with the -fshort-enums flag when compiling KnightCap 
(a chess program) with egcs-1.1.1.  The problem does not occur with
gcc-2.7.2.3 so I believe it is egcs-specific.

The code snippet below illustrates the bug.  Without -fshort-enums the 
"bug" function runs through the loop once, printing 64 values, and
then the program terminates.  With -fshort-enums on (as the KnightCap
Makefile does by default) the loop never terminates - it prints values 
from 0 to 255, ad infinitum.


----------------------cut here----------------------------------------

typedef enum {A1=0, A2, A3, A4, A5, A6, A7, A8,
              B1, B2, B3, B4, B5, B6, B7, B8,
              C1, C2, C3, C4, C5, C6, C7, C8,
              D1, D2, D3, D4, D5, D6, D7, D8,
              E1, E2, E3, E4, E5, E6, E7, E8,
              F1, F2, F3, F4, F5, F6, F7, F8,
              G1, G2, G3, G4, G5, G6, G7, G8,
              H1, H2, H3, H4, H5, H6, H7, H8} SquareT;

typedef SquareT Square;

bug(){
	Square p;
	for (p=A1;p<=H8;p++){
		printf("%d\n", (int)p);
	}
}

main(int argc, char **argv){
	bug();
}

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic