Article View: gnu.gcc.bug
Article #451bug in assignment containing side-effect
From: Paul SPEE
Date: Tue, 11 Jul 1989 05:36
Date: Tue, 11 Jul 1989 05:36
26 lines
956 bytes
956 bytes
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
Technical Details
Message-ID:
<366@qmfl.qmflp.JUNET>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!tut.cis.ohio-state.edu!cs.utexas.edu!pp!milano!bigtex!rena!kogwy!ccut!titcca!anprda!qmfl!speeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!tut.cis.ohio-state.edu!cs.utexas.edu!pp!milano!bigtex!rena!kogwy!ccut!titcca!anprda!qmfl!spee From: spee@qmfl.qmflp.JUNET (Paul SPEE) Newsgroups: gnu.gcc.bug Subject: bug in assignment containing side-effect Message-ID: <366@qmfl.qmflp.JUNET> Date: 11 Jul 89 05:36:53 GMT Reply-To: spee%qmflp.junet@RELAY.CS.NET (Paul SPEE) Organization: Quantum Magneto Flux Logic Project, Tsukiji, Tokyo Lines: 26