public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: John Love-Jensen <eljay@adobe.com>
To: <palvarado@ietec.org>, GCC-help <gcc-help@gcc.gnu.org>
Subject: Re: Undesired automatic cast, workarounds?
Date: Tue, 05 Aug 2008 18:43:00 -0000	[thread overview]
Message-ID: <C4BE093B.32C60%eljay@adobe.com> (raw)
In-Reply-To: <200808050828.00033.palvarado@ietec.org>

Hi Pablo,

> for some reason now the operator+ automatically converts the ubyte to int,

That's correct.  That's what the compiler should do.

> ... generating in the above code a warning.

What warnings are you enabling?  That should not be a default warning (but I
don't have GCC 4.3.1 at my disposal to confirm).

> This has been ok with all previous gcc compilers.

All previous GCC compilers promote unsigned char to int.  (I don't know of
any that promote unsigned char to unsigned int, but it could happen in some
uncommon kinds of architectures.)

> Is there any way to deactivate this?

There should be a -Wno-blah switch to turn off the warning.  But I'm
surprised that it is enabled in the first place.

The only way to deactivate promoting an unsigned char to int is to use a
different language which does not do that promotion.

Both C and C++ promote.

> I mean, not only the warning but avoiding the unnecesary casts?

To avoid the casts, use int or unsigned int instead of unsigned char.

HTH,
--Eljay

  reply	other threads:[~2008-08-05 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-05 14:27 Pablo Alvarado
2008-08-05 18:43 ` John Love-Jensen [this message]
     [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=C4BE093B.32C60%eljay@adobe.com \
    --to=eljay@adobe.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=palvarado@ietec.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).