linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Kamil Dudka <kdudka@redhat.com>,
	Christopher Li <sparse@chrisli.org>,
	linux-sparse@vger.kernel.org
Subject: Re: Sparse crash when mixing int and enum in ternary operator
Date: Tue, 09 Mar 2010 15:11:57 -0500	[thread overview]
Message-ID: <1268165517.23196.22.camel@mj> (raw)
In-Reply-To: <20100309191551.GB4586@feather>

On Tue, 2010-03-09 at 11:15 -0800, Josh Triplett wrote:
> On Tue, Mar 09, 2010 at 08:06:23PM +0100, Kamil Dudka wrote:
> > On Tuesday 09 of March 2010 19:35:19 Pavel Roskin wrote:
> > > I removed the outside conditional, and sparse would still crash on this:
> > >
> > > crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK);
> > >
> > > but not on this:
> > >
> > > crypto_has_alg(alg, type, mask ? mask: CRYPTO_ALG_TYPE_MASK);
> > >
> > > Apparently, the "?:" notation is confusing sparse now.
> > 
> > To be frank, I've never seen that notation before.  From what I understand, 
> > the variants above should be equivalent with each other, right?
> 
> Yes, except that the first variant would not evaluate "mask" twice, even
> if it consisted of an expression with side effects.  See
> http://gcc.gnu.org/onlinedocs/gcc/Conditionals.html .
> 
> (When I go to look up something in the GCC manual, more often than not I
> end up in Chapter 6, "Extensions to the C Language Family". :) )

Ironically, the fix for :? may benefit from that operator:

do_warn_for_enum_conversions(expr->cond_true ?: expr->conditional, type);
do_warn_for_enum_conversions(expr->cond_false ?: expr->conditional, type);

At least I was able to run sparse on the whole kernel (wireless-testing,
which is based on 2.6.34-rc1) without crashing or reporting anything
strange.

Actually, omitting the false conditional appears to be invalid.

-- 
Regards,
Pavel Roskin

  reply	other threads:[~2010-03-09 20:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09  1:24 Sparse crash when mixing int and enum in ternary operator Pavel Roskin
2010-03-09  5:43 ` Christopher Li
2010-03-09 13:46   ` Kamil Dudka
2010-03-09 18:26     ` Pavel Roskin
2010-03-09 18:35     ` Pavel Roskin
2010-03-09 19:06       ` Kamil Dudka
2010-03-09 19:15         ` Josh Triplett
2010-03-09 20:11           ` Pavel Roskin [this message]
2010-03-09 20:29             ` Kamil Dudka
2010-03-09 23:30               ` Kamil Dudka
2010-03-10  1:09                 ` Pavel Roskin
2010-03-10 16:05                   ` Kamil Dudka
2010-03-10 20:27                     ` Pavel Roskin
2010-03-10 20:44                       ` Kamil Dudka
2010-03-10 21:03                       ` Kamil Dudka
2010-03-10 21:56                     ` Christopher Li
2010-03-13 17:22                       ` Kamil Dudka
2010-03-21 15:27                         ` Kamil Dudka
2010-03-24 10:07                           ` Christopher Li
2010-03-24 10:51                             ` Kamil Dudka
2010-03-27  9:16                             ` Kamil Dudka
2010-03-27  9:29                               ` Josh Triplett
2010-03-27  9:53                                 ` [PATCH] eliminate insane conversions from int to enum Kamil Dudka
2010-03-29 18:11                                   ` Christopher Li
2010-03-29 18:05                                 ` Sparse crash when mixing int and enum in ternary operator Christopher Li
2010-03-29 18:17                                   ` Kamil Dudka
2010-03-29 18:48                                     ` Christopher Li
2010-03-29 19:23                                       ` Kamil Dudka
2010-03-30  5:29                                         ` Pavel Roskin
2010-03-29 21:26                                   ` Josh Triplett

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=1268165517.23196.22.camel@mj \
    --to=proski@gnu.org \
    --cc=josh@joshtriplett.org \
    --cc=kdudka@redhat.com \
    --cc=linux-sparse@vger.kernel.org \
    --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).