This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Do not warn about zero-as-null when NULL is used.
- From: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 25 May 2018 20:45:51 +0300
- Subject: Re: [C++ PATCH] Do not warn about zero-as-null when NULL is used.
- References: <CAFk2RUZ0bcf9KhamgJbdmZLMVE7h-TvHjEjp+CmQYgdhW-bDdQ@mail.gmail.com> <CADzB+2mkOKnOHmP6+zaMnHs-FuoN9XhKqQax0jHJuVvzM+=t9A@mail.gmail.com> <CAFk2RUa38UFO3jYNbgQY=WLKNcet2a=2_su7a7y9eVghxygpLA@mail.gmail.com>
On 25 May 2018 at 20:38, Ville Voutilainen <ville.voutilainen@gmail.com> wrote:
> On 25 May 2018 at 20:27, Jason Merrill <jason@redhat.com> wrote:
>> On Thu, May 24, 2018 at 8:04 PM, Ville Voutilainen
>> <ville.voutilainen@gmail.com> wrote:
>>> I smacked my head against conversion_null_warnings for a while,
>>> and then I realized that we could just stop convert_like_real from
>>> changing the node type for null_node.
>>
>> Won't that sometimes mean that the result has the wrong type? If we
>> convert NULL to short, we want the result to have type short.
>
> None of our tests revealed any regressions with the change; the change passes
> the full suite. And apparently the removed code in convert_like_real doesn't
> affect that; implicit and explicit conversions from NULL to short still convert
> to short, and code like auto x = NULL; still converts to unsigned long.
As far as I can see, cp_convert_to_pointer does convert NULL to the "right" kind
of integer constant, it's just that convert_like_real doesn't do it
earlier. The earlier
conversion caused the inability to diagnose the conversion properly in
cp_convert_to_pointer,
but that earlier conversion doesn't seem to have other effects.