Marking select(2) as restrict

Garrett Wollman wollman at csail.mit.edu
Wed Feb 21 20:27:22 UTC 2018


<<On Wed, 21 Feb 2018 22:10:02 +0200, Konstantin Belousov <kostikbel at gmail.com> said:

> Undefined != broken, whatever some compiler vendors try to bluff.

No, undefined behavior means the application is wrong.  Literally
anything may happen; the compiler does not enter into it.  The
compiler is not involved when you free() a pointer into the stack, or
pass a null pointer into a library routine that unconditionally
dereferences it, or update a string literal; nor is it involved when
you pass pointers that alias to a library routine that expects them to
point to different objects.

In the particular case of select(), there are no guarantees as to the
order in which the fd_set objects pointed to by readfds, writefds, and
exceptfds will be updated, so applications which alias them are
clearly wrong and have been since this interface was introduced in
4.2BSD.

-GAWollman



More information about the freebsd-standards mailing list