#include <stdio.h>
int main(void)
{
char * p = "bugfix";
p += 4;
p--;
puts(p);
return 0;
}
This program under Pelles C 6.50.8 RC #4 prints an empty line :( Expected result: "fix" must be printed.
After changing to:
static const char * p = "bugfix";
it works as expected.
Ro much optimized by the compiler. If it stores the string as locale string, it seems to optimize the storage for the string. So there is only "ix" on the stack and p points to the not initialized character before the 'i', which is in this case a 0x00, and the output for this is an empty line.
Edit:
I decided to retract my statement earlier.
This because I investigated the issue further and you're quite right.
It seems the optimization is premature.