[PATCH] add support for -Wmismatched-dealloc
Joseph Myers
joseph@codesourcery.com
Tue Dec 15 01:01:53 GMT 2020
On Mon, 14 Dec 2020, Martin Sebor via Libc-alpha wrote:
> > I spent some time working around this but in the end it turned out
> > to be too convoluted so I decided to make the attribute a little
> > smarter. Instead of associating all allocation functions with all
> > deallocation functions (such as fdopen, fopen, fopen64, etc. with
> > fclose, freopen, and freopen64) I changed it so that an allocator
> > only needs to be associated with a single deallocator (a reallocator
> > also needs to be associated with itself). That makes things quite
> > a bit simpler.
[...]
> The GCC patches have now been committed and the dependency resolved.
I've looked at the attribute documentation now in GCC, but I'm afraid I'm
unable to understand from that documentation why the proposed glibc patch
constitutes a valid way of specifying that, for example, it's valid to use
freopen as a deallocator for FILE pointers opened by functions whose
attribute only mentions fclose. Unless there's something I'm missing in
the documentation or a separate documentation patch that's not yet
committed, I think more work is needed on the GCC documentation to make
clear the semantics the glibc patch is asserting for valid combinations of
allocators and deallocators, so that those semantics can be reviewed for
correctness.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list