2 new testcases
Mark Mitchell
mark@markmitchell.com
Wed Jul 1 10:47:00 GMT 1998
>
> On Tue, Jun 30, 1998 at 08:35:05PM -3100, H.J. Lu wrote:
> > --- /dev/null Wed Dec 31 16:00:00 1969
> > +++ execute/980630-1.c Tue Jun 30 20:07:49 1998
> > @@ -0,0 +1,17 @@
> > +long A [2] = {0};
> > +long B [2] = {2, 0};
> > +
> > +main ()
> > +{
> > + unsigned int i;
> > + long long u;
> > + for (i = 0; i < 2; i+=2)
> > + {
> > + u = A [i] + B [i];
> > + u = (long long) (*(((long *)&( u ))+1)) + A [i+1] + B [i+1];
>
> This line will fail with big endian or -fstrict-aliasing.
>
Ooops. I forgot about endian. We can move it to gcc.dg and
test it on little endian machines only, like x86. As for
-fstrict-aliasing, I have submitted a patch for the bug.
It works with -fstrict-aliasing.
It may at the moment. But, your code is not conforming ANSI C, even
assuming the existence of long long. You are referencing a variable of
type `long long' (namely `u') through a pointer of type `long'.
That's a no-no. If you want to submit this test case, you should
explicitly add -fno-strict-aliasing to the compiler options. IMO, you
should write this code differently. The only even semi-portable way
to do what you are doing is to use type-punning through unions.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
More information about the Gcc-patches
mailing list