public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mike Stump <mikestump@comcast.net>
To: Richard Sandiford <rdsandiford@googlemail.com>
Cc: Kenneth Zadeck <zadeck@naturalbridge.com>,
	rguenther@suse.de, gcc-patches <gcc-patches@gcc.gnu.org>,
	r.sandiford@uk.ibm.com
Subject: Re: wide-int branch now up for public comment and review
Date: Sat, 24 Aug 2013 03:34:00 -0000	[thread overview]
Message-ID: <E6AC8DB1-54FC-4809-8675-CF9344E75AE1@comcast.net> (raw)
In-Reply-To: <87ppt4e9hg.fsf@talisman.default>

On Aug 23, 2013, at 8:02 AM, Richard Sandiford <rdsandiford@googlemail.com> wrote:
>>  * When a constant that has an integer type is converted to a
>>    wide-int it comes in with precision 0.  For these constants the
>>    top bit does accurately reflect the sign of that constant; this
>>    is an exception to the normal rule that the signedness is not
>>    represented.  When used in a binary operation, the wide-int
>>    implementation properly extends these constants so that they
>>    properly match the other operand of the computation.  This allows
>>    you write:
>> 
>>               tree t = ...
>>               wide_int x = t + 6;
>> 
>>    assuming t is a int_cst.
> 
> This seems dangerous.  Not all code that uses "unsigned HOST_WIDE_INT"
> actually wants it to be an unsigned value.  Some code uses it to avoid
> the undefinedness of signed overflow.  So these overloads could lead
> to us accidentally zero-extending what's conceptually a signed value
> without any obvious indication that that's happening.  Also, hex constants
> are unsigned int, but it doesn't seem safe to assume that 0x80000000 was
> meant to be zero-extended.
> 
> I realise the same thing can happen if you mix "unsigned int" with
> HOST_WIDE_INT, but the point is that you shouldn't really do that
> in general, whereas we're defining these overloads precisely so that
> a mixture can be used.

So, I don't like penalizing all users, because one user might write incorrect code.  We have the simple operators so that users can retain some of the simplicity and beauty that is the underlying language.  Those semantics are well known and reasonable.  We reasonably match those semantics.  At the end of the day, we have to be able to trust what the user writes.  Now, a user that doesn't trust themselves, can elect to not use these functions; they aren't required to use them.

  parent reply	other threads:[~2013-08-24  1:59 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13 20:57 Kenneth Zadeck
2013-08-22  8:25 ` Richard Sandiford
2013-08-23 15:03 ` Richard Sandiford
2013-08-23 21:01   ` Kenneth Zadeck
2013-08-24 10:44     ` Richard Sandiford
2013-08-24 13:10       ` Richard Sandiford
2013-08-24 18:16         ` Kenneth Zadeck
2013-08-25  7:27           ` Richard Sandiford
2013-08-25 13:21             ` Kenneth Zadeck
2013-08-24 21:22       ` Kenneth Zadeck
2013-08-24  0:03   ` Mike Stump
2013-08-24  1:59   ` Mike Stump
2013-08-24  3:34   ` Mike Stump [this message]
2013-08-24  9:04     ` Richard Sandiford
2013-08-24 20:46   ` Kenneth Zadeck
2013-08-25 10:52   ` Richard Sandiford
2013-08-25 15:14     ` Kenneth Zadeck
2013-08-26  2:22     ` Mike Stump
2013-08-26  5:40       ` Kenneth Zadeck
2013-08-28  9:11       ` Richard Biener
2013-08-29 13:34         ` Kenneth Zadeck
2013-08-25 18:12   ` Mike Stump
2013-08-25 18:57     ` Richard Sandiford
2013-08-25 19:59       ` Mike Stump
2013-08-25 20:11       ` Mike Stump
2013-08-25 21:38     ` Joseph S. Myers
2013-08-25 21:53       ` Mike Stump
2013-08-28  9:06   ` Richard Biener
2013-08-28  9:51     ` Richard Sandiford
2013-08-28 10:40       ` Richard Biener
2013-08-28 11:52         ` Richard Sandiford
2013-08-28 12:04           ` Richard Biener
2013-08-28 12:32             ` Richard Sandiford
2013-08-28 12:49               ` Richard Biener
2013-08-28 16:58                 ` Mike Stump
2013-08-28 21:15                   ` Kenneth Zadeck
2013-08-29  3:18                     ` Mike Stump
2013-08-28 16:08         ` Mike Stump
2013-08-29  7:42           ` Richard Biener
2013-08-29 19:34             ` Mike Stump
2013-08-30  8:51               ` Richard Biener
2013-09-01 19:26               ` Richard Sandiford
2013-09-05 21:00                 ` Richard Sandiford
2013-09-06  0:10                   ` Mike Stump
2013-08-28 13:11     ` Kenneth Zadeck
2013-08-29  0:15     ` Kenneth Zadeck
2013-08-29  9:13       ` Richard Biener
2013-08-29 12:38         ` Kenneth Zadeck
2013-08-24 18:42 ` Florian Weimer
2013-08-24 19:48   ` Kenneth Zadeck

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=E6AC8DB1-54FC-4809-8675-CF9344E75AE1@comcast.net \
    --to=mikestump@comcast.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=r.sandiford@uk.ibm.com \
    --cc=rdsandiford@googlemail.com \
    --cc=rguenther@suse.de \
    --cc=zadeck@naturalbridge.com \
    /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).