Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2018 13:45:26 +0100
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        Mark Millard <marklmi26-fbsd@yahoo.com>, FreeBSD Hackers <freebsd-hackers@freebsd.org>, FreeBSD Standards <freebsd-standards@freebsd.org>, Kevin Lo <kevlo@freebsd.org>
Subject:   Re: Marking select(2) as restrict
Message-ID:  <20180226134526.425aa33c@kalimero.tijl.coosemans.org>
In-Reply-To: <20180226200951.V2634@besplex.bde.org>
References:  <CAF6rxg=h_oMiUu7P=GAOQf_OySQM2w31hg6Kas%2B3jeEM3qq_Cg@mail.gmail.com> <CAF6rxgnt9c0n8i-nHQwoKGbZKF2hM5AZqEJnz0CLo26XOO4_sg@mail.gmail.com> <20180221032247.GA81670@ns.kevlo.org> <CAF6rxg=WwqeBnmJzfOZgtwrYesXPfvJFeaVmQwtTa_89_sxaJg@mail.gmail.com> <CANCZdfo46bhfaRpbqOmJjk4%2B=1R2c5kvmrJPENaxNgK==5M4kg@mail.gmail.com> <CAF6rxg=wNVgDUF9o744ngmzPNeHB3hqdrLufy=yS3D4osczxFQ@mail.gmail.com> <20180221104400.GU94212@kib.kiev.ua> <20180222112752.10da7e51@kalimero.tijl.coosemans.org> <20180222105608.GE94212@kib.kiev.ua> <20180225214813.776a9f58@kalimero.tijl.coosemans.org> <2909E983-953A-4463-959C-F3C386BC6C9A@yahoo.com> <20180226135457.B1203@besplex.bde.org> <1A2830F4-A00B-4C56-8D28-C46715DC7C9E@yahoo.com> <20180226200951.V2634@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 26 Feb 2018 21:00:21 +1100 (EST) Bruce Evans <brde@optusnet.com.au> wrote:
> For select() with restrict, I think the compiler cannot assert that
> the args don't overlap since (even without the detailed specification
> and Example 3), the compiler cannot know if select() modifies its args.
> For all that the compiler knows, select() might be a stub that never
> modifies or even reads anything.  I think doing no accesses satifies
> the constraints of restrict.  It might be valid for the compiler to
> assert that the (values pointed to by) the fdset args don't change for
> select(nfd, &fdset, &fdset, &fdset, &tv) (because any write access
> through an fdset type would give undefined behaviour on the other fdset
> args; tv can still change since it has a different type).  But this is
> precisely what is wanted for the original example where we only care
> about the return value -- then fdset is indeterminate after the call
> so we shouldn't use it; the compiler is unlikely to optimize the non-use
> of it and the worst that it can do is add a runtime assertion that the
> arg didn't change.

I don't think the compiler can assert that fdset is unmodified.  It's
valid for select to modify fdset through one pointer if it doesn't
dereference the other two.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180226134526.425aa33c>