public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/111638] New: GLIBCXX_MAYBE_UNDERSCORED_FUNCS autoconf macro doesn't work
Date: Fri, 29 Sep 2023 13:17:16 +0000	[thread overview]
Message-ID: <bug-111638-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2023-09-29 13:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-29 13:17 redi at gcc dot gnu.org [this message]
2023-11-11  0:43 ` [Bug libstdc++/111638] " cvs-commit at gcc dot gnu.org
2023-11-12 21:38 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111638-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).