https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71302
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |dmalcolm at gcc dot
gnu.org
Target Milestone|--- |9.0
Summary|-Wzero-as-null-pointer-cons |[9 Regression]
|tant: misleading caret |-Wzero-as-null-pointer-cons
|location for pointer in |tant: misleading caret
|function call |location for pointer in
| |function call
--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #2)
> (In reply to Manuel López-Ibáñez from comment #1)
> > I don't think this can be fixed without having locations for constants (or
> > at least for the arguments of function calls, thus fixing PR43486.)
>
> Even though bug 43486 isn't quite fixed yet, David Malcolm still made some
> major progress on it for GCC 9.
In GCC 8, actually.
Unfortunately, it seems to have regressed on trunk.
g++ 7.4 has false positives for NULL, and uses the closing parenthesis of the
call as the location:
<source>: In function 'int main()':
<source>:16:14: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
Function1(0);
^
<source>:17:17: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
Function1(NULL);
^
<source>:18:17: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
Function2(0, 0);
^
<source>:19:20: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
Function2(NULL, 0);
^
g++ 8.2 gets it right:
<source>: In function 'int main()':
<source>:16:13: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
Function1(0);
^
<source>:18:13: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
Function2(0, 0);
^
g++ trunk seems to have regressed: it uses the closing parenthesis of the call
as the location (but doesn't have the false positives from above):
<source>: In function 'int main()':
<source>:16:14: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
16 | Function1(0);
| ^
<source>:18:17: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
18 | Function2(0, 0);
| ^
I'm investigating the regression.