Marking select(2) as restrict

Conrad Meyer cem at
Thu Feb 22 20:04:53 UTC 2018

On Thu, Feb 22, 2018 at 11:42 AM, Eitan Adler <lists at> wrote:
> On 22 February 2018 at 06:43, Warner Losh <imp at> wrote:
>> If the compilers affirmatively fails when this happens
> Compilers cannot fail since errors are only detectable at runtime.

This is simply not true.  *Some* instances of this error could only be
detected at run time, but compilers can and do perform some kinds of
static analysis for warning/error purposes and for optimization.  In
the extremely common case where fdsets are local or global variables,
the compiler could easily detect when the same pointer is passed
multiple times.  If we're unlucky, it produces no warning and
"optimizes" the undefined behavior into something awful.

In my local testing, neither Clang nor GCC6 produces any error or
warning for this, which is disappointing.

More information about the freebsd-standards mailing list