public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Undesired automatic cast, workarounds?
@ 2008-08-05 14:27 Pablo Alvarado
  2008-08-05 18:43 ` John Love-Jensen
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Alvarado @ 2008-08-05 14:27 UTC (permalink / raw)
  To: gcc-help

Hello all,

I tried yesterday GCC 4.3.1 for the first time, and I encountered a bad 
surprise.  If I do

typedef unsigned char ubyte;
ubyte a,b,c;
c=a+b;
c+=a;

for some reason now the operator+ automatically converts the ubyte to int, 
generating in the above code a warning.  This has been ok with all previous 
gcc compilers.  Is there any way to deactivate this?  I mean, not only the 
warning but avoiding the unnecesary casts?  This new behaviour is even worse 
in the following cases:

typedef signed char byte;
byte a,b,c;
...
a=-b;  // the operator- also produces an int !

or 

c=b/a; // the operator/ also produces an int

in the later cases the casts to are absolutelly innecessary, since the results 
are always in range (assuming a!=0 of course)!

Any hints will be very welcome,

Pablo

^ permalink raw reply	[flat|nested] 3+ messages in thread
[parent not found: <200808051555.28989.palvarado@ietec.org>]

end of thread, other threads:[~2008-08-06 12:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-05 14:27 Undesired automatic cast, workarounds? Pablo Alvarado
2008-08-05 18:43 ` John Love-Jensen
     [not found] <200808051555.28989.palvarado@ietec.org>
2008-08-06 12:10 ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).