T
Tomás Ó hÉilidhe
I'm writing a program currently that was working perfectly until I
decided to compile it with "-O3" in gcc (-O3 specifies optimisation of
the third level).
Anyway, I found the problem. I had the following function:
void StrToLower(char *p)
{
while ( *p++ = tolower( (char unsigned)*p ) );
}
I changed it to the following and now it works properly:
void StrToLower(char *p)
{
for ( ; *p = tolower((char unsigned)*p); ++p);
}
I'm not entirely convinced however that there's a sequence point
violation in the following:
*p++ = tolower( (char unsigned)*p );
Any thoughts? There should be a sequence point at tolower's evaluation of
its arguments... right?
decided to compile it with "-O3" in gcc (-O3 specifies optimisation of
the third level).
Anyway, I found the problem. I had the following function:
void StrToLower(char *p)
{
while ( *p++ = tolower( (char unsigned)*p ) );
}
I changed it to the following and now it works properly:
void StrToLower(char *p)
{
for ( ; *p = tolower((char unsigned)*p); ++p);
}
I'm not entirely convinced however that there's a sequence point
violation in the following:
*p++ = tolower( (char unsigned)*p );
Any thoughts? There should be a sequence point at tolower's evaluation of
its arguments... right?