https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111638
Bug ID: 111638 Summary: GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- In linkage.m4 we have: dnl dnl Define autoheader template for using the underscore functions dnl For each parameter, create a macro where if func doesn't exist, dnl but _func does, then it will "#define func _func". dnl dnl GLIBCXX_MAYBE_UNDERSCORED_FUNCS AC_DEFUN([GLIBCXX_MAYBE_UNDERSCORED_FUNCS], [AC_FOREACH([glibcxx_ufunc], [$1], [AH_VERBATIM(_[]glibcxx_ufunc, [#if defined (]AS_TR_CPP(HAVE__[]glibcxx_ufunc)[) && ! defined (]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[) # define ]AS_TR_CPP(HAVE_[]glibcxx_ufunc)[ 1 # define ]glibcxx_ufunc[ _]glibcxx_ufunc[ #endif])]) ]) dnl dnl Check to see if the (math function) argument passed is dnl 1) declared when using the c++ compiler dnl 2) has "C" linkage dnl 3) if not, see if 1) and 2) for argument prepended with '_' dnl dnl Define HAVE_CARGF etc if "cargf" is declared and links dnl dnl argument 1 is name of function to check dnl dnl ASSUMES argument is a math function with ONE parameter dnl dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1], [ GLIBCXX_CHECK_MATH_DECL_1($1) if test x$glibcxx_cv_func_$1_use = x"yes"; then AC_CHECK_FUNCS($1) else GLIBCXX_CHECK_MATH_DECL_1(_$1) if test x$glibcxx_cv_func__$1_use = x"yes"; then AC_CHECK_FUNCS(_$1) fi fi GLIBCXX_MAYBE_UNDERSCORED_FUNCS($1) ]) Which results in output like this in c++config.h #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf #endif But this is completely incompatible with the logic in <cmath>. For a target where _acosf is present, c++config.h will do: # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf Then <cmath> will do something like: #undef acosf #ifdef _GLIBCXX_HAVE_ACOSF using ::acosf; #endif So HAVE_ACOSF is defined, but the using-declaration will fail, because acosf was actually just a macro for _acosf which has been undefined. If the macros in linkage.m4 still have any value, we would need to output something like this to c++config.h: #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 inline __decltype(_acosf(0)) acosf(__decltype(_acosf(0)) __x) { return ::_acosf(__x); } #endif That would define a real function that <cmath> can refer to. But maybe we should just remove it all. The #define acosf _acosf stuff was added in 2000 by g:54fa741538eaf41ed84093cc5245f41119a8e969 so maybe it's no longer even needed.