bind(2): Missing [[gnu::nonnull]]

Andreas Schwab schwab@linux-m68k.org
Sat Dec 3 19:05:33 GMT 2022


On Dez 03 2022, Xi Ruoyao via Libc-alpha wrote:

> Currently the man page says:
>
> EFAULT: addr points outside the user's accessible address space.
>
> And bind(2) indeed sets errno to EFAULT and return -1 when NULL is
> passed as addr.

You can never depend on EFAULT for invalid addresses.

> gnu::nonnull is not only a diagnostic attribute: it also allows the
> compiler to assume addr is never NULL.  i. e. if addr was gnu::nonnull
> and bind(2) is called with addr == NULL, the behavior would be
> undefined.

It is already undefined now, so this would be a valid change.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


More information about the Libc-alpha mailing list