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

--- Comment #65 from Kees Cook <kees at outflux dot net> ---
(In reply to Alejandro Colomar from comment #64)
> How about having two macros?  One that works for non-attributed pointers,
> and other that works for attributed ones.  And use the appropriate one for
> each of them.
> 
> If you accidentally use the one that uses the builtin, it'll cause a
> compiler error.

No, that's exactly what I am trying avoid. There should be no additional work
needed beyond adding "counted_by" to the struct.

> alloc_no_attribute() would work everywhere, and alloc() only where the
> attribute is used.

We are actively trying to reduce the number of duplicate APIs. The compiler has
everything it needs to do this without duplicating an API.

> You could still do this with my approach.  And there are less NULL pointers
> around, which would get messy.

I disagree: all the NULL checks are constant and removed at compile time. There
is literally no benefit at all to having 2 APIs. :)

Reply via email to