https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108871

--- Comment #7 from Jonny Grant <jg at jguk dot org> ---
(In reply to Jakub Jelinek from comment #6)
> (In reply to Jonathan Wakely from comment #5)
> > (In reply to Andrew Pinski from comment #3)
> > > *** Bug 108893 has been marked as a duplicate of this bug. ***
> > 
> > N.B. this one is about __attribute__((access(read_only, 1))) not nonnull.
> > The docs already seem to imply that it requires a non-null pointer:
> > 
> >   The read_only access mode specifies that the pointer to which it applies
> > is used to
> >   read the referenced object but not write to it. Unless the argument
> > specifying the
> >   size of the access denoted by size-index is zero, the referenced object
> > must be
> >   initialized.
> > 
> > If a non-zero size implies an initialized object, then it also implies a
> > non-null pointer (since a null pointer doesn't point to an initialized
> > object).
> > 
> > I don't know if we want this PR to be specific to the nonnull attribute, or
> > if it makes sense to use it for access(read_only) too.
> 
> On the other side, looking at glibc sources, access attributes there are
> used on many functions together with nonnull attributes for the same
> arguments and in many cases in places where there are not nonnull
> attributes.  So, making access attribute imply non-null might not be
> desirable in real-world unless it is already implied.
> So it might be just that it is badly documented.

Hi Jakub, Did you manage to get gcc to give a build warning from those
__attr_access read_only lines in glibc?  I haven't found a way to activate any
build warnings.  

attribute nonnull seems to be used by optimizer to remove any NULL checks it
finds.

Reply via email to