[PATCH v7] libio: Add nonnull attribute for most FILE * arguments in stdio.h
Xi Ruoyao
xry111@xry111.site
Mon Sep 25 14:47:14 GMT 2023
On Mon, 2023-09-25 at 10:30 -0400, Zack Weinberg wrote:
> On Mon, Sep 25, 2023, at 10:29 AM, Xi Ruoyao wrote:
> > On Mon, 2023-09-25 at 10:10 -0400, Zack Weinberg wrote:
> >
> > > (It's probably fine if compilers treat calls that pass a NULL pointer to
> > > a __nonnull argument as noreturn, or if they replace them with a trap
> > > instruction or a call to abort(). The danger I foresee is from any
> > > circumstance where NULL checks and side effects that happen *before* the
> > > bad call can get deleted.)
> >
> > Regarding this, gcc man page says:
> >
> > -fisolate-erroneous-paths-attribute
> > Detect paths that trigger erroneous or undefined behavior due to a
> > null value being used in a way forbidden by a "returns_nonnull" or
> > "nonnull" attribute. Isolate those paths from the main control
> > flow and turn the statement with erroneous or undefined behavior
> > into a trap. This is not currently enabled, but may be enabled by
> > -O2 in the future.
>
> This is not a clear statement that the path will not be deleted as unreachable,
> nor is it a promise never to do so in the future.
Then let's revert 71d9e0fe766a3c22a730995b9d024960970670af and backport
the revert into 2.38 branch.
The problem is this commit causes some GCC analyzer test failures. If
we'll use nonnull I can fix the test cases at GCC side, but if we'll not
use nonnull I don't want to spend my time adding some special cases into
test files. And I don't want everyone seeing the failures to continue
blaming on me.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Libc-alpha
mailing list