Re: GCC 4.0 code generation bug
Re: GCC 4.0 code generation bug
- Subject: Re: GCC 4.0 code generation bug
- From: Steve Checkoway <email@hidden>
- Date: Fri, 20 Aug 2010 01:14:05 -0700
On Aug 19, 2010, at 17:02 , Matthew Litwin wrote:
I believe I've run into a code generation bug in GCC 4.0 / Xcode
3.2.2, which occurs under optimization. GCC 4.2 doesn't show the
problem, but we're using 4.0 in order to deploy on Tiger. The code
below is a boiled down version of the problem. With that code, the
problem occurs at -O2, rather than the -Os we are in fact using in
our non-boiled down project, but this is the construct that is
giving us problems.
I see the same incorrect behavior with -O1.
Questions:
1) Am I hallucinating, or is this in fact a code-gen bug, rather
than programmer error?
It looks like a codegen bug to me. If you compile with -S and take a
look at the assembly, Get_g is only called a single time and that
return value is used in both places. This holds true for ppc, ppc64,
i386, and x86_64.
Compiling with -Os seems optimizes Get_g out. In fact, it behaves like
int main()
{
if( 0 == f[g] )
{
g = 1;
puts( "Good" );
}
return 0;
}
2) If it is a code-gen bug, what's the recommended workaround
(judicious use of "volatile" seems to work, for example, but there
are other twiddles).
Making g volatile seems to be sufficient, but it really shouldn't be
needed.
--
Steve Checkoway
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden