[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Casting pointer to short or _Bool (grischka6.1)

From: Rob Landley
Subject: Re: [Tinycc-devel] Casting pointer to short or _Bool (grischka6.1)
Date: Wed, 2 May 2007 14:00:08 -0400
User-agent: KMail/1.9.1

On Tuesday 01 May 2007 8:55 pm, David A. Wheeler wrote:
> Here's another grishka-based patch for tcc.  It applies cleanly to Landley's 
fork, and I believe it'll apply cleanly to mainline.
> Support casting pointer to short or _Bool (grischka-2005-09-25 bugfix 6.1).
> This patch was originally posted in grischka's 2005-09-25 email as a
> "required fix" 6 (subfix 6.1) to compile gcc 2.95. It was tweaked by
> David A. Wheeler to merge the test case into the standard tcc test suite,
> and the test case now uses the correct formats %hd and %hhd (not %d).

Hmmm...  Does gcc print a warning?  The typecast is indeed dodgy, but it's 
also explicit.  The code _asked_ to do something stupid.  I assume the main 
problem is endianness, since I believe word size for char, short, int, and 
long are finally somewhat portable between c99 and the LP64 standard:


Or does it do this on a normal assignment, rather than just a typecast?  (In 
which case we should be warning about an assignment from pointer to int as 
well, since that's nonportable to 64-bit targets, which tcc will need 
soonish.  (It should be pointer to long, guaranteed portable on both 32 and 
64 bit Unix by the LP64 standard.))

I'm not quite sure under whih circumstances gen_cast is called, let's see...  
Possibly the warning should be in gen_assign_cast() instead?

> I intentionally put the test case in a different place from my previous
> posting.  That way, grishka6.1 and 6.2 can be applied separately. 

I'm happy to apply it to my fork, but I'd prefer to tweak the warning one way 
or the other, and would like to hear your opinion on that first...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]