From: Pablo Alvarado <palvarado@ietec.org>
To: gcc-help@gcc.gnu.org
Subject: Undesired automatic cast, workarounds?
Date: Tue, 05 Aug 2008 14:27:00 -0000 [thread overview]
Message-ID: <200808050828.00033.palvarado@ietec.org> (raw)
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
next reply other threads:[~2008-08-05 14:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-05 14:27 Pablo Alvarado [this message]
2008-08-05 18:43 ` John Love-Jensen
[not found] <200808051555.28989.palvarado@ietec.org>
2008-08-06 12:10 ` Eljay Love-Jensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808050828.00033.palvarado@ietec.org \
--to=palvarado@ietec.org \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).