On Thu, 25 Aug 2022 at 17:12, François Dumont via Libstdc++ wrote: > > I spent more time on this. > > Is there some discussion in the C++ Standard Committee to do something > like what I've done ? I guess adding nullptr_t overloads for all the > methods taking pointer is not an option, is it ? No, I don't think so. That doesn't really help anyway, it would only trigger if somebody calls the function with the nullptr literal, which seems unlikely. It wouldn't help for starts_with((const char*)0) or passing a pointer variable that happens to be null. Passing a literal nullptr to those functions is just dumb, I don't think we should waste our time (and slow down compilation) by handling it. If they cannot be called with a null pointer then they should use __attribute__((__nonnull__)), and let the compiler handle it. That's more reliable, works without assertions enabled, and handles (const char*)0 as well as literal nullptr constants. I'll test the attached patch, which does that. > Note that compilation fails but despite the dg-do xfail the test ends up > FAIL and not XFAIL. Is this the correct syntax: > // { dg-do compile { target c++2a xfail *-*-* } } > ? No, xfail means fails at runtime. You would want to use just { target c++20 ) and then add dg-error to the lines that are expected to trigger errors, or dg-warning for warnings.