All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolai Stange <nicstange@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Nicolai Stange <nicstange@gmail.com>,
	viro@ZenIV.linux.org.uk, josh@joshtriplett.org
Subject: Re: [PATCH RFC 00/13] improve constexpr handling
Date: Wed, 05 Aug 2015 09:24:39 +0200	[thread overview]
Message-ID: <878u9qci4o.fsf@gmail.com> (raw)
In-Reply-To: <20150723184723.GA1605@cloud> (josh@joshtriplett.org's message of "Thu, 23 Jul 2015 11:47:23 -0700")

josh@joshtriplett.org writes:
> On Thu, Jul 23, 2015 at 11:13:57AM +0200, Nicolai Stange wrote:
>> josh@joshtriplett.org writes:
>> >> Since the additional information on expressions obtained through the
>> >> first two parts is rather pointless without making any use of it, I
>> >> implemented part three, the checking of static storage duration
>> >> objects' initializers for constness.
>> >> This part is the reason why there is a 'RFC' tag in the subject.
>> >> It is up to you to decide whether letting sparse check for C99
>> >> conformity is a valuable thing to have or whether being stricter than
>> >> GCC is counter-productive/completely idiotic.
>> >
>> > I think it's absolutely a valuable thing to have.  It may or may not be
>> > the right *default* behavior, but having an appropriate -W option to
>> > enable it would be a good start.
>> 
>> My next resend will contain such a -Wcheck-static-initializers then.
>
> <bikeshed>Shouldn't it be something like -Wnon-constant-initializer,
> since that's what it checks for?</bikeshed>
>
>> However, I will delay that resend in order to be able to incorporate
>> other reviews arriving in the meantime.
>
> Sounds reasonable.
>
>> > On Thu, Jul 23, 2015 at 12:54:25AM +0200, Nicolai Stange wrote:
>> >> sparse now finds 519 occurences of non-const initializers of static
>> >> storage duration objects, 474 of which are located in drivers/acpi
>> >> and stem from this subsystem's custom offsetof macro implemented by
>> >> means of taking pointer differences.
>> >
>> > Ideally, I'd suggest that ACPICA should add a translation from
>> > ACPI_OFFSET to offsetof as part of its Linux-izing scripts.
>> >
>> > That said, I also can't think of an obvious reason why ACPI_OFFSET
>> > *should* be considered non-constant.  Perhaps there's a detail in the
>> > C99 spec that explains why what it does isn't OK, but it *seems* like it
>> > should be a compile-time constant expression.  I've CCed Al Viro, who
>> > knows the C99 constant expression rules very well; Al, could you provide
>> > some clarity here?  The ACPI_OFFSET macro in question expands to this:
>> >
>> > (acpi_size) (((u8 *) (void *) ((&(((struct some_struct *) 0)->fieldname)))) - ((u8 *) (void *) (((void *) (void *) 0))))
>> >
>> > Does the -> make this non-constant?
>> 
>> No, it is the pointer difference. At least to my interpretion of C99
>> [6.6(9)] which might be arguable.
>> Upon your request, I could relax these constraints as I have did already for
>> some special cases of conditionals in [11/13].
>
> Ah, I see.  I don't know whether relaxing that makes sense or not; Al?

Just a friendly ping to get some more reviews to consider in my next
resend, especially on [13/13] and whether to relax the constant
expression rules to treat pointer differences of address constants as
(arithmetic or integer) constant expressions.

  reply	other threads:[~2015-08-05  7:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 22:54 [PATCH RFC 00/13] improve constexpr handling Nicolai Stange
2015-07-23  0:37 ` josh
2015-07-23  9:13   ` Nicolai Stange
2015-07-23 18:47     ` josh
2015-08-05  7:24       ` Nicolai Stange [this message]
2015-08-10  0:06         ` Christopher Li
2015-12-29  8:34           ` Nicolai Stange
2016-01-09 18:25   ` Luc Van Oostenryck
2016-01-09 22:05     ` Nicolai Stange
2016-01-11 17:46       ` 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=878u9qci4o.fsf@gmail.com \
    --to=nicstange@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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.