From: David Addison <addy@quadrics.com>
To: "'axp-list@redhat.com'" <axp-list@redhat.com>
Subject: RE: Weird Compaq CCC / GCC interaction ?
Date: Tue, 26 Sep 2000 18:47:55 +0100 [thread overview]
Message-ID: <010C86D15E4D1247B9A5DD312B7F5AA70BEC2F@stegosaurus.bristol.quadrics.com> (raw)
It seems that the MAGIC value 0xc00fc00f is being sign extended as a
negative number. Changing the printf for the working case and printing out
longs instead of ints shows;
GOOD baseAddr ffffffffc00fc00f == ffffffffc00fc00f
Even casting MAGIC to an unsigned int doesn't make it a postive 64-bit
number. Declaring it as 'const unsigned int' does though.
So gcc is clearing the top 4-bytes of the return value in fn.c and so the
main code compares 0x00000000c00fc00f with 0xffffffffc00fc00f in the if
statement.
Is there a way to define the MAGIC value unsigned ? 0xc00fc00fU doesn't seem
to have any effect.
Addy.
> -----Original Message-----
> From: Larry Sendlosky [mailto:larry@scrugs.lkg.dec.com]
> Sent: 26 September 2000 18:26
> To: axp-list@redhat.com
> Subject: Re: Weird Compaq CCC / GCC interaction ?
>
>
>
>
> I haven't seen any of this thread, but the quoted spec is correct and
> makes sense. Given the example below
>
> MAGIC is an unsigned int (32bits) with value 0xc00fc00f. The compiler
> should generate 0x00000000c00fc00f for the register value. This is
> "sign extending" an unsigned int (there is no sign bit or it's
> "inferred" to be zero).
>
> If MAGIC was defined as int 0xc00fc00f, then the register value
> should be 0xffffffffc00fc00f. int 0xc00fc00f is a negative number.
>
>
> larry
>
>
> > >
> > > According to the Calling Standard for Alpha Systems,
> Section 4.1.5 "Unused
> > > Bits in Passed Data," both signed and unsigned ints
> should be passed
> > > sign-extended in registers.
> >
> > Good to know but why this convention? If I follow implications
> > correctly (which is a big IF) then if I take results of
> such function
> > returning unsigned int, like in the example, and will cast
> its result to
> > long then I may get a negative number. OTOH if I do:
> >
> > #define MAGIC 0xc00fc00fU
> > ...
> > printf ("%ld\n", (long)MAGIC);
> > ...
> >
> > then result is positive and I would be quite surprised otherwise.
> > Or this Standard makes this also into a bug and expects that the
> > cast above is equivalent to (long)((int)MAGIC)? If yes then again
> > why?
> >
> > Michal
> >
> >
> >
> > _______________________________________________
> > Axp-list mailing list
> > Axp-list@redhat.com
> > https://listman.redhat.com/mailman/listinfo/axp-list
> >
>
>
>
> ______________________________________________________________________
> Larry Sendlosky ATS
> larry@scrugs.lkg.dec.com (978) 506-6640 Compaq
> ----------------------------------------------------------------------
>
>
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
>
next reply other threads:[~2000-09-26 17:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-26 17:47 David Addison [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-09-26 18:52 Weird Compaq CCC / GCC interaction ? Larry Sendlosky
2000-09-26 17:25 Larry Sendlosky
2000-09-26 18:01 ` Michal Jaegermann
2000-09-27 3:17 ` Richard Henderson
2000-09-26 13:59 David Addison
2000-09-26 15:36 ` Ivan Kokshaysky
2000-09-26 8:55 David Addison
2000-09-26 9:41 ` Andrei A. Dergatchev
2000-09-26 10:12 ` Nikita Schmidt
2000-09-26 16:02 ` Michal Jaegermann
2000-09-26 12:23 ` Ivan Kokshaysky
2000-09-26 13:57 ` Ivan Kokshaysky
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox