linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: linux-sparse@vger.kernel.org, Christopher Li <sparse@chrisli.org>
Subject: Re: [PATCH] fix typing error in compound assignment
Date: Sat, 10 Dec 2016 02:14:00 +0000	[thread overview]
Message-ID: <20161210021400.GG1555@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20161207143342.88825-1-luc.vanoostenryck@gmail.com>

On Wed, Dec 07, 2016 at 03:33:42PM +0100, Luc Van Oostenryck wrote:
> But what is really done currently is something like:
> 	x = x + (typeof(x)) a;
> In other words, the left-hand side is casted to the same type as the
> rhs and the operation is always done with this type, neglecting the
> usual conversions and thus forcing the operation to always be done
> with the rhs type, here 'int' instead of 'long'.

Addition is a bad example, actually - your variant (promotions + operaton +
cast down to the first argument due to assignment) will yield the same value.
It's division where the real trouble happens -
	unsigned n1 = 1, n2 = 1;
	long v = -1;
	n1 /= v;
	n2 /= (unsigned)v;

should yield n1 == ~0U, n2 == 0.  And yes, the current logics in sparse
does not distinguish between those.  So ACK on the fix, but you want
a better testcase.

  reply	other threads:[~2016-12-10  2:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07 14:33 [PATCH] fix typing error in compound assignment Luc Van Oostenryck
2016-12-10  2:14 ` Al Viro [this message]
2016-12-10  6:25   ` Luc Van Oostenryck
  -- strict thread matches above, loose matches on Subject: below --
2016-12-10  9:52 Luc Van Oostenryck
2016-12-10 21:22 ` Ramsay Jones
2016-12-10 22:40   ` Luc Van Oostenryck

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=20161210021400.GG1555@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=sparse@chrisli.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 NNTP newsgroup(s).