[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 --- Comment #11 from Jonathan Wakely --- That's now PR 85553
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 --- Comment #10 from Jonathan Wakely --- This causes a regression for: using T = decltype(nullptr); const constexpr T foo{}; np.cc:2:23: error: ‘(const T)nullptr’ is not a constant expression const constexpr T foo{}; ^
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 --- Comment #9 from Jakub Jelinek --- Author: jakub Date: Wed Apr 11 15:55:15 2018 New Revision: 259325 URL: https://gcc.gnu.org/viewcvs?rev=259325=gcc=rev Log: PR c++/70808 * g++.dg/warn/Wzero-as-null-pointer-constant-7.C: Require c++11 effective target. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-7.C
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 Paolo Carlini changed: What|Removed |Added Status|ASSIGNED|RESOLVED CC|jason at gcc dot gnu.org, | |paolo.carlini at oracle dot com| Resolution|--- |FIXED Assignee|paolo.carlini at oracle dot com|unassigned at gcc dot gnu.org Target Milestone|--- |8.0 --- Comment #8 from Paolo Carlini --- Fixed.
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 --- Comment #7 from paolo at gcc dot gnu.org --- Author: paolo Date: Tue Apr 10 22:34:06 2018 New Revision: 259303 URL: https://gcc.gnu.org/viewcvs?rev=259303=gcc=rev Log: /cp 2018-04-10 Paolo CarliniPR c++/70808 * init.c (build_zero_init_1): Handle NULLPTR_TYPE_P being true of the type like TYPE_PTR_OR_PTRMEM_P. /testsuite 2018-04-10 Paolo Carlini PR c++/70808 * g++.dg/warn/Wzero-as-null-pointer-constant-7.C: New. Added: trunk/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-7.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/init.c trunk/gcc/testsuite/ChangeLog
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 Paolo Carlini changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com --- Comment #6 from Paolo Carlini --- Mine.
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 --- Comment #5 from Paolo Carlini --- In fact, there is sort-of an inconsistency in build_zero_init_1 which explains the inconsistency in the original testcase: else if (TYPE_PTR_OR_PTRMEM_P (type)) init = fold (convert (type, nullptr_node)); else if (SCALAR_TYPE_P (type)) init = fold (convert (type, integer_zero_node)); thus std::nullptr_t is handled as a generic scalar, whereas int* is not. Changing the above as in the below makes sense to me and would have the effect of suppressing the warning for both the testcases here. Index: init.c === --- init.c (revision 259287) +++ init.c (working copy) @@ -180,7 +180,7 @@ build_zero_init_1 (tree type, tree nelts, bool sta items with static storage duration that are not otherwise initialized are initialized to zero. */ ; - else if (TYPE_PTR_OR_PTRMEM_P (type)) + else if (TYPE_PTR_OR_PTRMEM_P (type) || NULLPTR_TYPE_P (type)) init = fold (convert (type, nullptr_node)); else if (SCALAR_TYPE_P (type)) init = fold (convert (type, integer_zero_node));
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 --- Comment #4 from Paolo Carlini --- NB: I played only with the *second* testcase, under the assumption that it was the a reduced version of the original one but likely that isn't the case. I'll check.
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 Paolo Carlini changed: What|Removed |Added CC||jason at gcc dot gnu.org, ||paolo.carlini at oracle dot com --- Comment #3 from Paolo Carlini --- I spent only a few minutes on this and I'm not at all sure it's a bug. As I read the standard - and our implementation - we are doing value-initializaation here. In turn, for a scalar type like std::nullptr_t, that means zero-initialization (11.6/6), which, in turn, means converting the integer literal 0 to T, thus the warning. If there is a mistake in my reasoning above, adding a special case to our implementation would be easy, I think.
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 Eric Gallager changed: What|Removed |Added Keywords||diagnostic Status|UNCONFIRMED |NEW Last reconfirmed||2017-08-22 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Eric Gallager --- Confirmed for both examples.
[Bug c++/70808] Spurious -Wzero-as-null-pointer-constant for nullptr_t
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70808 Jaak Ristioja changed: What|Removed |Added CC||jaak at ristioja dot ee --- Comment #1 from Jaak Ristioja --- A minimum example I've found for this is: void f() { decltype(nullptr)(); } With -std=c++11 the warning is emitted in versions 4.8.5, 4.9.3, 5.3.0, 5.4.0 and 6.2.0, but not in 4.7.4.