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

--- Comment #8 from uecker at gcc dot gnu.org ---
(In reply to Alejandro Colomar from comment #7)
> (In reply to Konstantin Kharlamov from comment #5)
> > So basically -Wc++-compat warns about every heap memory allocation, of which
> > there are dozens and hundreds in every C file. This warning alone can't be
> > turned off. So apparently you're supposed to replace every memory allocation
> > with a custom macro that takes type of the variable as an additional
> > parameter just to shove in a cast.
> 
> Off-topic, but "replac[ing] every memory allocation with a custom macro that
> takes [the] type of the variable as an additional parameter just to shove in
> a cast" is actually a good thing.  It improves the safety of such calls.  I
> found and fixed several bugs in allocation calls in shadow utils thanks to
> these macros.
> 
> See:
> 
> <https://github.com/shadow-maint/shadow/commit/
> d81506de1e8e2ba544a30e54e863fcafda9cde86>
> <https://github.com/shadow-maint/shadow/commit/
> 191f04f7dcb92a2c7de99dbf1108563ea8832927>
> <https://github.com/shadow-maint/shadow/commit/
> 6e58c1275252f3314d1aa5cc4d7e7f9068e3a902>
> <https://github.com/shadow-maint/shadow/commit/
> efbbcade43ff2dca2b7a271dcbd186be08ac1913>
> <https://github.com/shadow-maint/shadow/commit/
> 09775d3718df216c75b62d73bbcc5aa060e0fc94>
> 
> Anyway, I hope my patch to add -Wunterminated-string-initialization is
> merged soon.  :)

Have you considered adding the alloc_size attribute to your allocation
functions?

Reply via email to