public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters
@ 2015-03-05 10:12 akim.demaille at gmail dot com
2015-03-05 20:57 ` [Bug c++/65323] " paolo.carlini at oracle dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: akim.demaille at gmail dot com @ 2015-03-05 10:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
Bug ID: 65323
Summary: -Wzero-as-null-pointer-constant stutters
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: akim.demaille at gmail dot com
While tracking a spurious warning about at 0 instead of nullptr, I stumbled on
the following case, where g++ is spitting its warning too many times (4.9 and
5).
struct foo
{
foo(void* = 0) {}
void fun(void* = 0) {}
void* p = 0;
};
int main()
{
foo f;
f.fun();
}
g++-mp-5 -std=c++14 -Wzero-as-null-pointer-constant foo.cc
foo.cc:3:15: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
foo(void* = 0) {}
^
foo.cc:3:15: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
foo.cc:4:20: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
void fun(void* = 0) {}
^
foo.cc:4:20: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
foo.cc:5:13: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
void* p = 0;
^
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] -Wzero-as-null-pointer-constant stutters
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
@ 2015-03-05 20:57 ` paolo.carlini at oracle dot com
2015-03-05 21:04 ` paolo.carlini at oracle dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-05 20:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This one should be easy to fix.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] -Wzero-as-null-pointer-constant stutters
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
2015-03-05 20:57 ` [Bug c++/65323] " paolo.carlini at oracle dot com
@ 2015-03-05 21:04 ` paolo.carlini at oracle dot com
2015-03-06 0:17 ` [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings paolo.carlini at oracle dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-05 21:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
2015-03-05 20:57 ` [Bug c++/65323] " paolo.carlini at oracle dot com
2015-03-05 21:04 ` paolo.carlini at oracle dot com
@ 2015-03-06 0:17 ` paolo.carlini at oracle dot com
2015-03-09 14:43 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-06 0:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|-Wzero-as-null-pointer-cons |[4.8/4.9/5 Regression]
|tant stutters |duplicate
| |-Wzero-as-null-pointer-cons
| |tant warnings
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is in fact a regression which started when check_default_argument got a
perform_implicit_conversion_flags call near the beginning.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
` (2 preceding siblings ...)
2015-03-06 0:17 ` [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings paolo.carlini at oracle dot com
@ 2015-03-09 14:43 ` rguenth at gcc dot gnu.org
2015-03-10 14:50 ` ktietz at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-03-09 14:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Priority|P3 |P2
Target Milestone|--- |4.8.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
` (3 preceding siblings ...)
2015-03-09 14:43 ` rguenth at gcc dot gnu.org
@ 2015-03-10 14:50 ` ktietz at gcc dot gnu.org
2015-03-10 15:24 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ktietz at gcc dot gnu.org @ 2015-03-10 14:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
Kai Tietz <ktietz at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ktietz at gcc dot gnu.org
--- Comment #3 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Hmm, the issue seems to be that we emit within check_default_argument () two
times the call to maybe_warn_zero_as_null_pointer_constant (). Once indirectly
via perform_implicit_conversion_flags () call, and then later on directly
within if-condition for returning nullptr_node.
It seems that second call is superflous in terms of warning. So I suggest the
following patch:
Index: decl.c
===================================================================
--- decl.c (Revision 221277)
+++ decl.c (Arbeitskopie)
@@ -11231,7 +11233,8 @@ check_default_argument (tree decl, tree arg, tsub
&& TYPE_PTR_OR_PTRMEM_P (decl_type)
&& null_ptr_cst_p (arg)
&& (complain & tf_warning)
- && maybe_warn_zero_as_null_pointer_constant (arg, input_location))
+ && c_inhibit_evaluation_warnings == 0
+ && !NULLPTR_TYPE_P(TREE_TYPE (arg)))
return nullptr_node;
/* [dcl.fct.default]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
` (4 preceding siblings ...)
2015-03-10 14:50 ` ktietz at gcc dot gnu.org
@ 2015-03-10 15:24 ` paolo.carlini at oracle dot com
2015-03-12 23:56 ` paolo at gcc dot gnu.org
2015-03-12 23:58 ` [Bug c++/65323] [4.8/4.9 " paolo.carlini at oracle dot com
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-10 15:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I sent a patch to the mailing list about this. If we don't want to apply it and
we want to be super-conservative, we can indeed simply do this, with a comment,
in my opinion:
@@ -11227,11 +11243,14 @@
LOOKUP_IMPLICIT);
--cp_unevaluated_operand;
+ /* FIXME: should be OK to just check
+ TYPE_PTR_OR_PTRMEM_P (decl_type) && null_ptr_cst_p (arg). */
if (warn_zero_as_null_pointer_constant
&& TYPE_PTR_OR_PTRMEM_P (decl_type)
&& null_ptr_cst_p (arg)
&& (complain & tf_warning)
- && maybe_warn_zero_as_null_pointer_constant (arg, input_location))
+ && c_inhibit_evaluation_warnings == 0
+ && !NULLPTR_TYPE_P (TREE_TYPE (arg)))
return nullptr_node;
/* [dcl.fct.default]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
` (5 preceding siblings ...)
2015-03-10 15:24 ` paolo.carlini at oracle dot com
@ 2015-03-12 23:56 ` paolo at gcc dot gnu.org
2015-03-12 23:58 ` [Bug c++/65323] [4.8/4.9 " paolo.carlini at oracle dot com
7 siblings, 0 replies; 9+ messages in thread
From: paolo at gcc dot gnu.org @ 2015-03-12 23:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Thu Mar 12 23:55:49 2015
New Revision: 221402
URL: https://gcc.gnu.org/viewcvs?rev=221402&root=gcc&view=rev
Log:
2015-03-12 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65323
* decl.c (check_default_argument): Don't call
maybe_warn_zero_as_null_pointer_constant.
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/65323] [4.8/4.9 Regression] duplicate -Wzero-as-null-pointer-constant warnings
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
` (6 preceding siblings ...)
2015-03-12 23:56 ` paolo at gcc dot gnu.org
@ 2015-03-12 23:58 ` paolo.carlini at oracle dot com
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-12 23:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|4.8.5 |5.0
Summary|[4.8/4.9/5 Regression] |[4.8/4.9 Regression]
|duplicate |duplicate
|-Wzero-as-null-pointer-cons |-Wzero-as-null-pointer-cons
|tant warnings |tant warnings
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 5.0, not worth fixing in 4.8/4.9.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-03-12 23:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 10:12 [Bug c++/65323] New: -Wzero-as-null-pointer-constant stutters akim.demaille at gmail dot com
2015-03-05 20:57 ` [Bug c++/65323] " paolo.carlini at oracle dot com
2015-03-05 21:04 ` paolo.carlini at oracle dot com
2015-03-06 0:17 ` [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings paolo.carlini at oracle dot com
2015-03-09 14:43 ` rguenth at gcc dot gnu.org
2015-03-10 14:50 ` ktietz at gcc dot gnu.org
2015-03-10 15:24 ` paolo.carlini at oracle dot com
2015-03-12 23:56 ` paolo at gcc dot gnu.org
2015-03-12 23:58 ` [Bug c++/65323] [4.8/4.9 " paolo.carlini at oracle dot com
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).