public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96543] New: null check on template pointer parameter fails
@ 2020-08-09 23:00 vlad at petric dot cc
  2020-08-10 10:21 ` [Bug c++/96543] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vlad at petric dot cc @ 2020-08-09 23:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96543

            Bug ID: 96543
           Summary: null check on template pointer parameter fails
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vlad at petric dot cc
  Target Milestone: ---

static unsigned c = 0;

template <unsigned* c>
struct A {
  static void test() {
    if constexpr (c) ++ *c;
  }
};

int main() {
  A<&c>::test();
  A<nullptr>::test();
}

The error is:

bug.cc: In instantiation of ‘static void A<c>::test() [with unsigned int* c =
(& c)]’:
bug.cc:11:10:   required from here
bug.cc:11:5: error: the address of ‘c’ will never be NULL [-Werror=address]
   11 |   A<&c>::test();

The only fix is to remove the if constexpr (nothing else helps).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/96543] null check on template pointer parameter fails
  2020-08-09 23:00 [Bug c++/96543] New: null check on template pointer parameter fails vlad at petric dot cc
@ 2020-08-10 10:21 ` redi at gcc dot gnu.org
  2020-08-10 12:52 ` vlad at petric dot cc
  2020-08-10 16:05 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-10 10:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96543

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-08-10
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is only a warning. Please use -Werror to report bugs about warnings.

It's only an error because you asked GCC to make it an error.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/96543] null check on template pointer parameter fails
  2020-08-09 23:00 [Bug c++/96543] New: null check on template pointer parameter fails vlad at petric dot cc
  2020-08-10 10:21 ` [Bug c++/96543] " redi at gcc dot gnu.org
@ 2020-08-10 12:52 ` vlad at petric dot cc
  2020-08-10 16:05 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vlad at petric dot cc @ 2020-08-10 12:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96543

--- Comment #2 from Vlad Petric <vlad at petric dot cc> ---
Got it, should I refile/change this bug?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/96543] null check on template pointer parameter fails
  2020-08-09 23:00 [Bug c++/96543] New: null check on template pointer parameter fails vlad at petric dot cc
  2020-08-10 10:21 ` [Bug c++/96543] " redi at gcc dot gnu.org
  2020-08-10 12:52 ` vlad at petric dot cc
@ 2020-08-10 16:05 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-10 16:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96543

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
No, it's fine. I've categorized it as a diagnostic bug, i.e. a bug in a
warning.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-10 16:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-09 23:00 [Bug c++/96543] New: null check on template pointer parameter fails vlad at petric dot cc
2020-08-10 10:21 ` [Bug c++/96543] " redi at gcc dot gnu.org
2020-08-10 12:52 ` vlad at petric dot cc
2020-08-10 16:05 ` redi at gcc dot gnu.org

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).