I know the code is weird :-) It works when you do -DUSE_VAR or remove -O2.
#include <string.h>
#include <stdio.h>
static char foo[1024];
int main(int argc, char * argv[])
{
size_t n;
char * x;
if (argc < 2)
return -1;
n = strlen(argv[1]);
strcpy(foo, argv[1]);
#ifdef USE_VAR
x = (n >= 4 && strcmp(&foo[n - 4], ".bar") == 0) ? &foo[n - 4] : &foo[n];
strcpy(x, ".baz");
#else
strcpy((n >= 4 && strcmp(&foo[n - 4], ".bar") == 0) ? &foo[n - 4] : &foo[n], ".baz");
#endif
printf("Result: %s\n", foo);
return 0;
}
Quote from: pocc -c -O2 test.c
test.c(21): warning #2242: Call to 'strcmp' removed. <-- WHY???
test.c(9): warning #2114: Local 'x' is not referenced.
test.c(6): fatal error: Internal error: 'Access violation' at 0x004a8b9c.
It is Pelles ISO C Compiler, Version 7.00.9 from the latest 7.0 RC3.
Yes, yuck about the code -- but at least I can reproduce the problem...