Variadic macros in installed headers
Florian Weimer
fw@deneb.enyo.de
Mon Nov 25 20:02:00 GMT 2019
* Martin Sebor:
>> We probably should have two variants for __write_only__, one that says
>> “will write”, and one for “may write”.
>
> You mean a "full write" to guarantee that exactly as many elements
> will have been written (as in memset) and "may write" to denote
> a partial write (like strcpy or fgets)? Those extensions certainly
> are possible within the attribute framework.
Exactly.
> PS I'm excited about this feature because besides out-of-bounds
> accesses, the attribute makes it possible (and I have patches)
> to detect uninitialized reads by annotated functions
> (-Wuninitialized), variables that are written to but not read
> from (-Wunused), and overlapping copies (-Wrestrict).
And the uninitialized-variable information will benefit from
information that shows that something has definitely been written to.
> In addition, the attribute also opens up similar optimization
> opportunities for user-defined functions as those compilers
> already take advantage of for built-in functions.
It may also allow us to remove some interceptors from the sanitizer
libraries.
More information about the Libc-alpha
mailing list