From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23316 invoked by alias); 1 Nov 2012 23:01:17 -0000 Received: (qmail 22407 invoked by uid 48); 1 Nov 2012 23:00:53 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52718] -Wzero-as-null-pointer-constant: misleading location for 0 as default argument Date: Thu, 01 Nov 2012 23:01: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-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com X-Bugzilla-Target-Milestone: 4.7.1 X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 X-SW-Source: 2012-11/txt/msg00092.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52718 Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #18 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez 2012-11-01 23:00:51 UTC --- (In reply to comment #15) > This is what I meant when I said that the issue is different, and is much= more > general than -Wzero-as-null-pointer-constant. Consider, eg, with -Woverfl= ow: >=20 > #pragma GCC system_header >=20 > class Foo > { > public: > Foo(signed char); > }; >=20 > class Bar > { > public: > Bar(Foo =3D 10000); > }; The issue is that literals don't have locations, so input_location is used.= And input_location here is in the main file, so system_header doesn't apply. Th= is is why input_location must die. Clang uses the correct location for warning, so it honors system_header (requires -Wsystem-headers): In file included from pr52718.c:1: ./pr52718.h:11:13: warning: implicit conversion from 'int' to 'signed char' changes value from 10000 to 16 [-Wconstant-conversion] Bar(Foo =3D 10000); ^~~~~ 1 warning generated. Ultimately, GCC needs to track the locations of literals like clang does. Everything else is a hack around the main issue. This is PR43486. There have been some recent attempts http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01222.html, but I am afraid th= at work seems stalled for lack of time/help.