I posted this to comp.std.c, but may be of interest here too:
Consider this:
extern void abort(void);
int main (void)
{
unsigned long long xx;
unsigned long long *x = (unsigned long long *) &xx;
*x = -3;
*x = *x * *x;
if (*x != 9)
abort ();
return(0);
}
lcc-win interprets
*x = -3;
as
*x = 4294967293;
since x points to an UNSIGNED long long.
I cast the 32 bit integer -3 into an unsigned integer
then I cast the result to an unsigned long long.
Apparently gcc disagrees.
Am I doing something wrong somewhere?
I should first cast into a long long THEN into an unsigned
long long?
Thanks for your help.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Consider this:
extern void abort(void);
int main (void)
{
unsigned long long xx;
unsigned long long *x = (unsigned long long *) &xx;
*x = -3;
*x = *x * *x;
if (*x != 9)
abort ();
return(0);
}
lcc-win interprets
*x = -3;
as
*x = 4294967293;
since x points to an UNSIGNED long long.
I cast the 32 bit integer -3 into an unsigned integer
then I cast the result to an unsigned long long.
Apparently gcc disagrees.
Am I doing something wrong somewhere?
I should first cast into a long long THEN into an unsigned
long long?
Thanks for your help.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Comment