Hello gho. Welcome on PellesC.
First of all please use current compiler version, 8.00.60, that you can download from
here.
There is no bug in the compiler for the snippet you have posted.
It is your code indeed to be bugged.
The problem is that you are comparing a
signed int, the loop variable
i, with the unsigned
size_t value returned from
strlen.
The compiler try to apply integer promotion privileging the type that can contain bigger value, the usigned, but sign change (equivalent to arithmetiic computation
0-val) generates an underflow. And this lead to wrong value.
See here (the concept is valid for overflow and underflow).
Casting the result from
strlen solve the problem:
int main(void)
{
char s[]="ABC";
for(int i=strlen(s);i>=-((int)strlen(s)); i--)
printf("%c",s[abs(i)]);
}
Of course on compilers not fully C99-C11 compliant it could eventually work...