From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124798 invoked by alias); 10 Mar 2015 14:50:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 124711 invoked by uid 48); 10 Mar 2015 14:50:12 -0000 From: "ktietz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/65323] [4.8/4.9/5 Regression] duplicate -Wzero-as-null-pointer-constant warnings Date: Tue, 10 Mar 2015 14:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: ktietz at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com X-Bugzilla-Target-Milestone: 4.8.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01130.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65323 Kai Tietz changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ktietz at gcc dot gnu.org --- Comment #3 from Kai Tietz --- 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]