[Bug c++/105885] [12/13 Regression] the address of 'template argument' will never be NULL warning

info@ebner-markus.de gcc-bugzilla@gcc.gnu.org
Thu Jun 23 09:59:55 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105885

--- Comment #3 from Markus Ebner <info@ebner-markus.de> ---
> I guess reporters reasoning is that ARG is defaulted to nullptr and that's the reason the diagnostic is unwanted?

I don't think it has any todo with whether nullptr is the default value for ARG
or not. Even if it's not the default value, it is a valid one the API's user
might explicitly pass to ARG.

My point rather is that, at least the way I understood it, `if constexpr` is
meant to implement conditional behavior based on a template argument. And it is
obvious that one of the if-branches is going to be comparing ARG to whatever
was passed in for it. So the compiler warning about this didn't make much sense
for me here.
Of course I could use template specialization to get rid of the warning, but
what if the function body is very long and only a tiny fraction of it needs
special handling for ARG? Then I would be copying the function body multiple
times for all specializations.


More information about the Gcc-bugs mailing list