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

--- Comment #11 from Alejandro Colomar <alx at kernel dot org> ---
(In reply to Konstantin Kharlamov from comment #10)
> (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.  :)
> 
> Thank you, these are interesting commits, but they just add the macros,
> don't seem to fix any bugs. Or if they do, the fixes are lost among other
> changes. I would rather be sold if you linked the fixes specifically 😊

Ahh, no I was remembering slightly wrong.  It was in neomutt(1) where I found
bugs.  I have some work-in-progress to add the same macros to neomutt(1), and
while doing the change, I found (and fixed) this bug from 1999:

<https://github.com/neomutt/neomutt/pull/4297>

Luckily, the program worked correctly, since it was using a type with a
compatible size.

Reply via email to