From: Jim Wilson <wilson@cygnus.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] gcc warnings on truncations?
Date: Thu, 31 Aug 2000 20:16:31 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590678205433@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590678205426@msgid-missing>
Is there a way to get gcc to warn (or ideally, error) on truncations to
shorter types? ie:
No.
The ISO C standard says that all expressions undergo default promotions, and
default promotions require promoting char/short to int. Thus even a simple
expression like
short s;
short t;
s = s + t;
results in truncation to a shorter type, because the result of s+t is an int
and this result must be truncated to fit in the short destination. A naive
implementation of this warning would give so many false warnings that it
wouldn't be very useful. An intelligent implementation could cut down on the
false warnings, but would take much longer to write, and hence it is unlikely
that anyone will bother.
Jim
prev parent reply other threads:[~2000-08-31 20:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-31 15:22 [Linux-ia64] gcc warnings on truncations? Ted Logan
2000-08-31 20:16 ` Jim Wilson [this message]
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=marc-linux-ia64-105590678205433@msgid-missing \
--to=wilson@cygnus.com \
--cc=linux-ia64@vger.kernel.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