[C++ PATCH] Do not warn about zero-as-null when NULL is used.

Ville Voutilainen ville.voutilainen@gmail.com
Fri May 25 17:51:00 GMT 2018


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.



More information about the Gcc-patches mailing list