https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68767
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think the problem here is that check_function_arguments_recurse just folds using fold_for_warn the condition, if instead of folding the condition the check_function_nonnull caller of check_function_arguments_recurse would fold_for_warn the whole argument and only then call check_function_arguments_recurse on it, it would rule out the NULL argument from there. But the disadvantage of that is that then we'd be warning on perhaps completely newly created trees that perhaps don't match very match the original, something the delayed folding rightly wants to avoid. Perhaps one option would be to do the non-NULL warning in two steps, where the first step is fold_for_warn the whole argument, recurse on it with a variant that will not fold_for_warn recursively (not needed) and just note if there is a need to warn instead of actually warning. And then, if this pass returned there is a reason to warn, call what we do now on the unfolded argument. Of course, the question is if the warning isn't really desirable, the user should really just choose some non-NULL magic value to pass in the impossible cases.