]> git.ipfire.org Git - thirdparty/autoconf.git/commit
AC_LANG_CALL(C++): Use ‘int’ for return type of conftest::$2.
authorZack Weinberg <zackw@panix.com>
Mon, 2 Nov 2020 01:04:19 +0000 (20:04 -0500)
committerZack Weinberg <zackw@panix.com>
Mon, 2 Nov 2020 01:04:19 +0000 (20:04 -0500)
commitd6fa54586d7989365cfc135bdb3ba5f7c3585a7d
tree0942d1c1434957dd0badaa8788ce374aa90a59d9
parent33c3a47c04ab70a4dd54963fe433a171bc03747f
AC_LANG_CALL(C++): Use ‘int’ for return type of conftest::$2.

Commit 326c9a547423d25c621bc5c0ef76edbf6eda8c92 introduced a custom
AC_LANG_CALL for C++.  Jani Välimaa reports in
https://lists.gnu.org/archive/html/bug-autoconf/2020-10/msg00054.html
that the new code does not handle AC_CHECK_LIB([foo], [main])
correctly.  This is not the recommended way to use AC_CHECK_LIB, but
it’s what you get if you autoupdate from AC_HAVE_LIBRARY, and some
people may not have bothered replacing main with a more appropriate
symbol.

This patch changes the return type of the fake function declaration
for AC_CHECK_LIB’s second argument to be ‘int’, which is sufficient to
make g++ 10.2.0 happy again.  We’re still on thin ice, unfortunately;
the code generated by AC_LANG_CALL *always* has undefined behavior, in
both C and C++, unless by chance the real prototype of the function
we’re probing for happens to match our fake declaration.  The only
permanent cure is to stop faking declarations, and that’s going to be
a challenge.

* lib/autoconf/c.m4 (AC_LANG_CALL(C++)): Use ‘int’ for the return
  type of the fake function declaration, to avoid problems when
  the function whose declaration we’re faking is ‘main’.
lib/autoconf/c.m4