spee@qmfl.qmflp.JUNET (Paul SPEE) (07/11/89)
I was pointed out the following bug:
#include <ctype.h>
char *string = "aBcDeF";
main()
{
char *p = string;
printf("%s\n", string);
while (*p)
{
*p++ = islower(*p) ? toupper(*p) : *p;
}
printf("%s\n", string);
}
SUN cc result: gcc v1.22 result:
aBcDeF aBcDeF
ABCDEF BCDEF
The cause is that gcc evaluates the lhs first. Is this fixed in later
version or is this ANSI behavior?
Paul Spee - spee%qmflp.junet@RELAY.CS.NET