public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109818] New: std::trunc() requires a <cmath> hack after building DJGPP
@ 2023-05-11 18:42 janezz55 at gmail dot com
  2023-05-11 20:11 ` [Bug libstdc++/109818] " redi at gcc dot gnu.org
                   ` (32 more replies)
  0 siblings, 33 replies; 34+ messages in thread
From: janezz55 at gmail dot com @ 2023-05-11 18:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109818

            Bug ID: 109818
           Summary: std::trunc() requires a <cmath> hack after building
                    DJGPP
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janezz55 at gmail dot com
  Target Milestone: ---

After building gcc/DJGPP, the installation requires the following hack:

sed -i '/{ return __builtin_tanh(__x); }/a\
\
  using ::trunc;\
\
#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO_FP\
  constexpr float\
  trunc(float __x)\
  { return __builtin_truncf(__x); }\
\
  constexpr long double\
  trunc(long double __x)\
  { return __builtin_truncl(__x); }\
#endif\
\
  template<typename _Tp>\
    constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, \
                                              double>::__type\
    trunc(_Tp __x)\
    { return __builtin_trunc(__x); }'
$pkgdir/usr/$_target/include/c++/$pkgver/cmath

The hack can be observed in action if you install/checkout:

https://aur.archlinux.org/packages/dosbox-gcc

If we don't apply the hack, gcc will complain about std::trunc() being
unavailable (compile error), if we try to compile an application requiring
std::trunc(), but not if it requires plain C trunc(). At least part of the
blame probably lies with DJGPP, not with libstdc++, but libstdc++ manages to
hack many other math.h functions (i.e. it seems to contain a template for the
hack, that it applies to many different math.h functions, just not to trunc()).
Perhaps a simple fix of adding trunc() to a list of functions, that need to be
hacked, is possible. Other math.h functions, not just trunc(), may also need to
be hacked into <cmath>.

Like most DJGPP-related bugs, this one is very old.

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2023-06-01 10:41 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 18:42 [Bug libstdc++/109818] New: std::trunc() requires a <cmath> hack after building DJGPP janezz55 at gmail dot com
2023-05-11 20:11 ` [Bug libstdc++/109818] " redi at gcc dot gnu.org
2023-05-11 20:13 ` redi at gcc dot gnu.org
2023-05-11 20:56 ` janezz55 at gmail dot com
2023-05-11 21:13 ` redi at gcc dot gnu.org
2023-05-11 21:14 ` redi at gcc dot gnu.org
2023-05-11 21:27 ` janezz55 at gmail dot com
2023-05-11 22:17 ` redi at gcc dot gnu.org
2023-05-12  5:21 ` janezz55 at gmail dot com
2023-05-12  6:05 ` janezz55 at gmail dot com
2023-05-12  8:07 ` redi at gcc dot gnu.org
2023-05-12  8:15 ` redi at gcc dot gnu.org
2023-05-12 10:14 ` janezz55 at gmail dot com
2023-05-12 10:16 ` redi at gcc dot gnu.org
2023-05-12 10:23 ` janezz55 at gmail dot com
2023-05-12 10:48 ` redi at gcc dot gnu.org
2023-05-12 10:55 ` redi at gcc dot gnu.org
2023-05-12 16:35 ` janezz55 at gmail dot com
2023-05-12 16:45 ` redi at gcc dot gnu.org
2023-05-12 21:21 ` redi at gcc dot gnu.org
2023-05-12 21:58 ` redi at gcc dot gnu.org
2023-05-12 22:01 ` redi at gcc dot gnu.org
2023-05-12 23:17 ` janezz55 at gmail dot com
2023-05-12 23:43 ` redi at gcc dot gnu.org
2023-05-13  1:19 ` janezz55 at gmail dot com
2023-05-13  9:55 ` redi at gcc dot gnu.org
2023-05-13 13:01 ` janezz55 at gmail dot com
2023-05-14 12:26 ` janezz55 at gmail dot com
2023-05-14 19:56 ` redi at gcc dot gnu.org
2023-05-14 20:02 ` redi at gcc dot gnu.org
2023-05-31 20:20 ` cvs-commit at gcc dot gnu.org
2023-05-31 20:24 ` redi at gcc dot gnu.org
2023-05-31 23:03 ` janezz55 at gmail dot com
2023-06-01 10:41 ` redi at gcc dot gnu.org

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).