I assume it’s not expected behavior, (using NULL or nullptr shouldn’t affect whether or not a return will ever be executed), therefore both issues should appear at once.
Thanks for raising this issue. This is indeed not the desired behavior for the code snippet you shared with us. Both issues related to the return statement return NULL; in foo (right after the loop) should be reported.
Whereas in C, NULL expands to ((void*)0), it expands to the compiler-built-in __null in C++, and this seems to cause the problem. Of course, this needs to be fixed. (I just checked using Compiler Explorer that manually replacing NULL by ((void*)0) causes both issues to be reported correctly, again.)
I will create a ticket and link it here such that you can track progress on this matter.