Re: How can Autoconf help with the transition to stricter compilation defaults?
Sam James <[email protected]> Wed, 16 Nov 2022 15:35:08 +0000
| Newsgroups | dev.linux.lists.c-std-porting |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_6CBEB47A-2714-479D-B040-A29DC401D735 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On 16 Nov 2022, at 15:27, Richard Biener <[email protected]> = wrote: >=20 > On Wed, Nov 16, 2022 at 4:02 PM Michael Matz via Gcc <[email protected]> = wrote: >>=20 >> Hey, >>=20 >> On Wed, 16 Nov 2022, Alexander Monakov wrote: >>=20 >>>> The idea is so obvious that I'm probably missing something, why = autoconf >>>> can't use that idiom instead. But perhaps the (historic?) reasons = why it >>>> couldn't be used are gone now? >>>=20 >>> Ironically, modern GCC and LLVM optimize '&foobar !=3D 0' to '1' = even at -O0, >>> and thus no symbol reference remains in the resulting assembly. >>=20 >> Err, right, *head-->table*. >> Playing with volatile should help: >>=20 >> char foobar(void); >> char (* volatile ptr)(void); >> int main(void) { >> ptr =3D foobar; >> return ptr !=3D 0; >> } >=20 > using printf for foobar this works even with GCC 2.95.2 and with trunk > and -Wall diagnoses >=20 > t.c:1:6: warning: conflicting types for built-in function 'printf'; > expected 'int(const char *, ...)' [-Wbuiltin-declaration-mismatch] > 1 | char printf(void); > | ^~~~~~ > t.c:1:1: note: 'printf' is declared in header '<stdio.h>' > +++ |+#include <stdio.h> > 1 | char printf(void); >=20 > so without -Werror this should be fine. >=20 Unrelated but I was a bit tempted to ask for throwing in = -Wbuiltin-declaration-mismatch to default -Werror while Clang 16 was at it, but I suppose we don't want = the world to burn too much, and it's got a very obvious usecase (this one) whereas = implicit func decls are too hard to justify. > Richard. --Apple-Mail=_6CBEB47A-2714-479D-B040-A29DC401D735 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iNUEARYKAH0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCY3UDLF8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MAAKCRBzhAn1IN+R kBCXAP9BdX2hjbcXRqMriNr3kyJZDWBGzB3la2YEKTaQudXIrgD/evpVBl5ulRGC YyuE53QVS/jN7AtnhcodJFt0q5cJJg8= =3Llf -----END PGP SIGNATURE----- --Apple-Mail=_6CBEB47A-2714-479D-B040-A29DC401D735--