All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>,
	Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: Sparse preprocessing bug with zero-arg variadic macros
Date: Thu, 31 Aug 2017 21:54:33 +0100	[thread overview]
Message-ID: <20170831205433.GQ5426@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CA+55aFy8sXZKibU_RK-+hu_SD-QMaWxxsAQNYALkmvMiYfEo=Q@mail.gmail.com>

On Thu, Aug 31, 2017 at 10:19:32AM -0700, Linus Torvalds wrote:
> On Thu, Aug 31, 2017 at 6:34 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> >
> > I think I'm seeing a bug in the sparse preprocessor.  I've reduced it to
> > the following test case.
> 
> I think the real reduced test-case is just this:
> 
>     #define ARGS_APPEND(...) ,## __VA_ARGS__
>     ARGS_APPEND()
> 
> and you can run if through "sparse -E" to see the comma (while gcc -E
> does not have it).
> 
> I'm adding Al to the cc list because he's the pre-processor person.
> Hopefully he has gotten out from under most of his emails from his
> move.
> 
> sparse gets it right if there is any non-VA_ARGS argument to the
> symbol, but not if __VA_ARGS__ is all of the argument to the macro.

Umm...  The problem is in collect_arguments() - it treats that as "argument
present, expands to empty" rather than "argument absent" in case when the
argument list consists of ... and no arguments are given.

What a mess...  Note that for non-vararg it *is* the right interpretation
(with #define A(x) [x] we will have A() interpreted as "empty token sequence
as the only argument", not "no arguments given").  For vararg case we
normally do not need to distinguish "not given" and "empty" - the only
thing that cares is exactly the ,## kludge.  There with
#define B(x,...) [x,##__VA_ARGS__]
B(1) and B(1,) yield [1] and [1,] resp.  And for everything other than
"just ..." we even get it right...

I see what's going on there; will post a fix in a few.

  reply	other threads:[~2017-08-31 20:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31 13:34 Sparse preprocessing bug with zero-arg variadic macros Josh Poimboeuf
2017-08-31 17:19 ` Linus Torvalds
2017-08-31 20:54   ` Al Viro [this message]
2017-08-31 21:09     ` Al Viro
2017-08-31 21:34       ` Josh Triplett
2017-08-31 21:48         ` Al Viro
2017-09-01  0:06           ` Christopher Li

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=20170831205433.GQ5426@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=jpoimboe@redhat.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.