[Bug c++/52718] -Wzero-as-null-pointer-constant: misleading location for 0 as default argument
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Nov 1 23:01:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52718
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #18 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 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 -Woverflow:
>
> #pragma GCC system_header
>
> class Foo
> {
> public:
> Foo(signed char);
> };
>
> class Bar
> {
> public:
> Bar(Foo = 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. This
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 = 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 that
work seems stalled for lack of time/help.
More information about the Gcc-bugs
mailing list