On Wed, May 06, 2009 at 12:19:55PM -0700, Ian Lance Taylor wrote:

> Stelian Pop <stel...@popies.net> writes:
> 
> > on TARGET_8W and TARGET_16:
> > 920928-1.c:
> >     1 struct{int c;}v;
> >     2 static long i=((char*)&(v.c)-(char*)&v)
> > 930326-1.c:
> >     1 struct
> >     2 {
> >     3   char a, b, f[3];
> >     4 } s;
> >     5
> >     6 long i = s.f-&s.b;
> > labels-3.c:
> >      9 int foo (int a)
> >     10 {
> >     11   static const short ar[] = { &&l1 - &&l1, &&l2 - &&l1 };
> >     12   void *p = &&l1 + ar[a];
> >     13   goto *p;
> >     14  l1:
> >     15   return 1;
> >     16  l2:
> >     17   return 2;
> >     18 }
> >
> > on TARGET_16W and TARGET_32: 20011114-1.c:
> >     1 extern void _text;
> >     2 static __SIZE_TYPE__ x = (__SIZE_TYPE__) &_text - 0x10000000L - 1;
> >
> > Are those tests expected to fail on my port or is that something I've
> > obviously done wrong ?
> 
> I don't see any particular reason that these tests should fail.  I
> hasten to add that these tests are not very important and it is unlikely
> that a failure to pass these tests will affect any actual program.
> 
> You didn't mention which version of gcc you are based on.  Do you have
> these patches?  If not, that may be your problem.

Sorry, fergot to say that I was using gcc 4.3.3, so yes, the patches
you mention are already in.

> Even if you do have those patches, that code is where I would start
> looking.  Your initializers are constant, but something in that area
> thinks that they are not constant.

I did spent a few hours looking but haven't had much luck.

I tried tracing this one:
> >     6 long i = s.f-&s.b;
and noticed that the pointers gets casted to 'long' (so they become integers
and no longer pointers) before the actual substraction is made.

Of course, replacing the 'long' with 'int' (on the incriminated targets,
where the real size of the pointer is 16 bit, the size of an 'int') makes
the code compile as a charm.

Stelian.
-- 
Stelian Pop <stel...@popies.net>

Reply via email to