Date: Sat, 27 Mar 93 07:54:31 MST From: bob AT plk DOT af DOT mil (Bob Conley) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Runtime error in gcc I have been using the djgpp MS-DOS port of GNU C for about a month, with good results. Recently I have uncovered what appears to be a problem with the compiler itself. I am new to the world of GNU C, so I am not sure if this is the appropriate manner to report a bug, but the following is submitted in the hope that whomever should review it will ultimately receive it. This occurs with version 2.22 of gcc; I have been unable to access the "barnacle" machine to verify that this is still the current version. The C procedure below triggers an execution error in gcc itself when compiled with the following command line (assuming the C procedure is placed in file "test.c"): gcc -O -c test.c The following error messages are emitted, and gcc aborts execution: Segmentation violation in pointer 0x0000006a at 40:5abdb Exception 14 (0xe) at eip=5abdb The error is not generated if the "-O" flag is not used; if the "-O" is used, the error is not generated if the list of "if( ... break; }" lines is shortened by one line. Nor is the error triggered if the entire structure recoded in a more conventional "if...then...else if" form. Here is the code which triggers the error; copy it to file test.c and execute the compiler command line shown above: void Procedure (v) int v; { int rc; while (1) { if (v < 2) { rc = 0; break; } if (v < 3) { rc = 1; break; } if (v < 5) { rc = 2; break; } if (v < 7) { rc = 3; break; } if (v < 11) { rc = 4; break; } if (v < 13) { rc = 5; break; } if (v < 17) { rc = 6; break; } if (v < 19) { rc = 7; break; } if (v < 23) { rc = 8; break; } if (v < 29) { rc = 9; break; } if (v < 31) { rc = 10; break; } if (v < 37) { rc = 11; break; } if (v < 41) { rc = 12; break; } if (v < 43) { rc = 13; break; } } } Bob Conley (505) 281-3354 (home) (505) 846-4844 (work) conley AT plk DOT af DOT mil