Re: [PATCH] _AC_C_C99_TEST_GLOBALS, _AC_C_C99_TEST_MAIN: support GCC's -Wc++-compat

Dave Hart <[email protected]> Wed, 13 Aug 2025 04:27:53 +0000
Newsgroups gmane.comp.sysutils.autoconf.patches
Message-ID <CAMbSiYAjCaO0vV4xWonRbO-FOp13=tK+Fd0YeWsZ8KSfhYHFuA@mail.gmail.com>
--000000000000846e6e063c3795a2
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Aug 7, 2025 at 8:52=E2=80=AFPM Paul Eggert <[email protected]> wro=
te:

> That thing with malloc goes too far. 'char *p =3D malloc (...);' is a goo=
d
> idiom in C, and it's silly and even counterproductive to require a cast.


I completely agree.  Adding the cast requires duplicating the type, slows
comprehension, and invites copy/paste mischief.


> I worked around the glitch by not using malloc.


I've seen this sort of change elsewhere.  I'm guessing at least one
compiler is emitting a warning without the superfluous cast.  Can someone
enlighten me why some folks apparently believe an implicit cast from void
pointer to another pointer is evil?

Cheers,
Dave Hart

--000000000000846e6e063c3795a2
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div><div class=3D"gmail_default" style=
=3D"font-family:&quot;trebuchet ms&quot;,sans-serif"><span style=3D"font-fa=
mily:Arial,Helvetica,sans-serif">On Thu, Aug 7, 2025 at 8:52=E2=80=AFPM Pau=
l Eggert &lt;<a href=3D"mailto:[email protected]">[email protected]</a>&g=
t; wrote:</span></div></div></div><div class=3D"gmail_quote gmail_quote_con=
tainer"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex">
That thing with malloc goes too far. &#39;char *p =3D malloc (...);&#39; is=
 a good <br>
idiom in C, and it&#39;s silly and even counterproductive to require a cast=
.</blockquote><div><br></div><div><div class=3D"gmail_default" style=3D"fon=
t-family:&quot;trebuchet ms&quot;,sans-serif">I completely agree.=C2=A0 Add=
ing the cast requires duplicating the type, slows comprehension, and invite=
s copy/paste mischief.</div></div><div>=C2=A0</div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,2=
04,204);padding-left:1ex">
I worked around the glitch by not using malloc.</blockquote><div><br></div>=
<div><div class=3D"gmail_default" style=3D"font-family:&quot;trebuchet ms&q=
uot;,sans-serif">I&#39;ve seen this sort of change elsewhere.=C2=A0 I&#39;m=
 guessing at least one compiler is emitting a warning without the superfluo=
us cast.=C2=A0 Can someone enlighten me why some folks apparently believe a=
n implicit cast from void pointer to another pointer is evil?</div></div><d=
iv class=3D"gmail_default" style=3D"font-family:&quot;trebuchet ms&quot;,sa=
ns-serif"><br></div><div><div dir=3D"ltr" class=3D"gmail_signature"><div di=
r=3D"ltr"><font face=3D"tahoma, sans-serif" color=3D"#666666">Cheers,<br>Da=
ve Hart</font></div></div></div><br class=3D"gmail-Apple-interchange-newlin=
e"></div></div>

--000000000000846e6e063c3795a2--