https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95354
--- Comment #5 from Haoxin Tu <haoxintu at gmail dot com> --- (In reply to Jonathan Wakely from comment #4) > (In reply to Haoxin Tu from comment #3) > > I see. Are there any cases that can trigger the UB of nonnull-attribute? I > > doubt the usage of “-fsanitize=nonnull-attribute” in GCC... > > Yes, just use the attribute correctly. > > Using: > > __attribute__((nonnull)) void has_nonnull_argument(int *p) { > ; > } > > will cause UBsan to diagnose it: > > nn.cc:7:25: runtime error: null pointer passed as argument 1, which is > declared to never be null Thanks, Jonathan, Got it ~