unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: maxim.cournoyer@gmail.com
Cc: 42392@debbugs.gnu.org
Subject: bug#42392: GCC includes ordering issue? g++: error: 'round' is not a member of 'std'
Date: Tue, 21 Jul 2020 17:27:22 +0200	[thread overview]
Message-ID: <87imegoplx.fsf@gnu.org> (raw)
In-Reply-To: <87imenk1ps.fsf@hurd.i-did-not-set--mail-host-address--so-tickle-me> (maxim cournoyer's message of "Thu, 16 Jul 2020 09:51:11 -0400")

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]

Hi,

maxim.cournoyer@gmail.com skribis:

> The following C++ snippet file reproduces it:
>
> // file: test.cpp
>
> #include <cmath>
> #include <iostream>
>
>
> int main() {
>     float x = 9.999;
>
>     std::cout << "rounding value: " << x << " --> " << std::round(x);
>
>     return 0;
> }
>
> // build with:
> // g++ -o test.o -std=c++17 test.cpp
>
>
> It affects only GCC 8 and newer, GCC 7 is fine.  The available "round"
> seems to be the one originating from tgmath.h (implementation detail of
> math.h AFAICT).
>
> The std::round function is conditionally defined in the C++ standard
> (since C++11) in the cmath header. It is supposed to also #undef the
> global "round" macro, but it doesn't, or perhaps the ordering of the
> includes is wrong and math.h gets included following cmath.
>
> In cmath, macros such as 'round' are undefined based on some
> conditions.  These conditions appear to be:
>
> __cplusplus >= 201103L and _GLIBCXX_USE_C99_MATH_TR1 and not _GLIBCXX_NO_C99_ROUNDING_FUNCS

See also
<https://lists.gnu.org/archive/html/guix-devel/2020-06/msg00096.html>,
which suggests rather a misconfiguration issue.

Comparing ‘c++config.h’ from GCC 7 (which works) and GCC 8 (the first
one that exhibits this problem), we see:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3069 bytes --]

diff -ubBr --show-c-function /gnu/store/93z2pmmpla1n47q3xivqyic4mwvy0r5q-gcc-toolchain-8.4.0/include/c\+\+/x86_64-unknown-linux-gnu/bits/c\+\+config.h /gnu/store/xa45bzcbib4zqa7gk70nb35dzzwyr376-gcc-toolchain-7.5.0/include/c\+\+/x86_64-unknown-linux-gnu/bits/c\+\+config.h
--- /gnu/store/xa45bzcbib4zqa7gk70nb35dzzwyr376-gcc-toolchain-7.5.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h	1970-01-01 01:00:01.000000000 +0100
+++ /gnu/store/93z2pmmpla1n47q3xivqyic4mwvy0r5q-gcc-toolchain-8.4.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h	1970-01-01 01:00:01.000000000 +0100

[...]

@@ -644,61 +619,61 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* Define to 1 if you have the `acosf' function. */
-#define _GLIBCXX_HAVE_ACOSF 1
+/* #undef _GLIBCXX_HAVE_ACOSF */
 
 /* Define to 1 if you have the `acosl' function. */
-#define _GLIBCXX_HAVE_ACOSL 1
+/* #undef _GLIBCXX_HAVE_ACOSL */
 
 /* Define to 1 if you have the `aligned_alloc' function. */
 #define _GLIBCXX_HAVE_ALIGNED_ALLOC 1
 
 /* Define to 1 if you have the `asinf' function. */
-#define _GLIBCXX_HAVE_ASINF 1
+/* #undef _GLIBCXX_HAVE_ASINF */
 
 /* Define to 1 if you have the `asinl' function. */
-#define _GLIBCXX_HAVE_ASINL 1
+/* #undef _GLIBCXX_HAVE_ASINL */
 
 /* Define to 1 if the target assembler supports .symver directive. */
 #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1
 
 /* Define to 1 if you have the `atan2f' function. */
-#define _GLIBCXX_HAVE_ATAN2F 1
+/* #undef _GLIBCXX_HAVE_ATAN2F */
 
 /* Define to 1 if you have the `atan2l' function. */
-#define _GLIBCXX_HAVE_ATAN2L 1
+/* #undef _GLIBCXX_HAVE_ATAN2L */
 
 /* Define to 1 if you have the `atanf' function. */
-#define _GLIBCXX_HAVE_ATANF 1
+/* #undef _GLIBCXX_HAVE_ATANF */
 
 /* Define to 1 if you have the `atanl' function. */
-#define _GLIBCXX_HAVE_ATANL 1
+/* #undef _GLIBCXX_HAVE_ATANL */
 
 /* Define to 1 if you have the `at_quick_exit' function. */
-#define _GLIBCXX_HAVE_AT_QUICK_EXIT 1
+/* #undef _GLIBCXX_HAVE_AT_QUICK_EXIT */
 
 /* Define to 1 if the target assembler supports thread-local storage. */
 /* #undef _GLIBCXX_HAVE_CC_TLS */
 
 /* Define to 1 if you have the `ceilf' function. */
-#define _GLIBCXX_HAVE_CEILF 1
+/* #undef _GLIBCXX_HAVE_CEILF */
 
 /* Define to 1 if you have the `ceill' function. */
-#define _GLIBCXX_HAVE_CEILL 1
+/* #undef _GLIBCXX_HAVE_CEILL */
 
 /* Define to 1 if you have the <complex.h> header file. */
-#define _GLIBCXX_HAVE_COMPLEX_H 1
+/* #undef _GLIBCXX_HAVE_COMPLEX_H */
 
 /* Define to 1 if you have the `cosf' function. */
-#define _GLIBCXX_HAVE_COSF 1
+/* #undef _GLIBCXX_HAVE_COSF */
 
 /* Define to 1 if you have the `coshf' function. */
-#define _GLIBCXX_HAVE_COSHF 1
+/* #undef _GLIBCXX_HAVE_COSHF */
 
 /* Define to 1 if you have the `coshl' function. */
-#define _GLIBCXX_HAVE_COSHL 1
+/* #undef _GLIBCXX_HAVE_COSHL */
 
 /* Define to 1 if you have the `cosl' function. */
-#define _GLIBCXX_HAVE_COSL 1
+/* #undef _GLIBCXX_HAVE_COSL */
 
 /* Define to 1 if you have the <dirent.h> header file. */
 #define _GLIBCXX_HAVE_DIRENT_H 1

[-- Attachment #3: Type: text/plain, Size: 4143 bytes --]


/tmp/guix-build-gcc-10.1.0.drv-0/build/prev-x86_64-unknown-linux-gnu/libstdc++-v3/config.log
reads this:

--8<---------------cut here---------------start------------->8---
configure:19924: checking for float trig functions
configure:19948:  /tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc/xgcc -shared-libgcc -B/tmp/guix-build-gcc-10.1.0.drv-0/build/./gcc -nostdinc++ -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs -L/tmp/guix-build-gcc-10.1.0.drv-0/build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/bin/ -B/gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/lib/ -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/include -isystem /gnu/store/jrzxs91zhpf6yr5fxisn3jjj7xai8zlk-gcc-10.1.0/x86_64-unknown-linux-gnu/sys-include   -fno-checking -c -fno-builtin -D_GNU_SOURCE  conftest.cpp >&5
In file included from /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/math.h:36,
                 from conftest.cpp:122:
/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/cmath:41:10: fatal error: bits/c++config.h: No such file or directory
   41 | #include <bits/c++config.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
configure:19948: $? = 1
configure: failed program was:

[...]

| /* end confdefs.h.  */
| #include <math.h>
| int
| main ()
| {
| acosf (0); asinf (0); atanf (0); cosf (0); sinf (0); tanf (0); coshf (0); sinhf (0); tanhf (0);
|   ;
|   return 0;
| }
configure:19962: result: no
--8<---------------cut here---------------end--------------->8---

At this point, we have:

--8<---------------cut here---------------start------------->8---
export CPLUS_INCLUDE_PATH=\
"/gnu/store/61pv34q6kad3cii1pngyairvxbxgdm1n-isl-0.22.1/include\
:/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/include\
:/gnu/store/5jf395qa3v4amdi60850rz2a15zlsrza-mpfr-4.0.2/include\
:/gnu/store/lgrnkwh7w5yawgqaglwj1pls5vwz1nz7-mpc-1.1.0/include\
:/gnu/store/243algr6h60j46spn5dqhjc4mhkd0a0p-libelf-0.8.13/include\
:/gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/include\
:/gnu/store/i8h2pcxqdq07ijm3ibkka8f4smn1w48v-bzip2-1.0.8/include\
:/gnu/store/9860f1abqj8wjjnwl8a9v54pdcc3bhgf-xz-5.2.4/include\
:/gnu/store/60g7r3l01fd7c58yjbm6krgcwj1jkpwg-file-5.38/include\
:/gnu/store/swqdvwri9dbv6zssg6v0by7l05hd6wxp-gawk-5.0.1/include\
:/gnu/store/hm40bxnv8jxmbc1lpb7zfimii4xm9m81-make-4.3/include\
:/gnu/store/m1z7cdbqsqyp9xnjw5cvlb4a7gkcg3m4-binutils-2.34/include\
:/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++\
:/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include\
:/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/include\
:/gnu/store/gfapkk5c6hvl1d94m4sqnhn7f9l5gqyh-linux-libre-headers-5.4.20/include"
--8<---------------cut here---------------end--------------->8---

but <bits/c++config.h> is in a directory not listed here:

--8<---------------cut here---------------start------------->8---
$ find /gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0 -name c++config.h
/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu/bits/c++config.h
--8<---------------cut here---------------end--------------->8---

‘gcc-final’ doesn’t have this problem because it depends on ‘libstdc++’
(separate package) where:

--8<---------------cut here---------------start------------->8---
$ find /gnu/store/v507xkc5flnzqa49yp41w5y611p4lqbg-libstdc++-7.5.0 -name c++config.h
/gnu/store/v507xkc5flnzqa49yp41w5y611p4lqbg-libstdc++-7.5.0/include/bits/c++config.h
--8<---------------cut here---------------end--------------->8---

So somehow the problems seems to be that ‘xgcc’ doesn’t search
‘gcc-7.5.0/include/c++/x86_64-unknown-linux-gnu’.  We could add it to
CPLUS_INCLUDE_PATH manually, but it seems to me we’re missing something.

Thoughts?

Thanks,
Ludo’.

  reply	other threads:[~2020-07-21 15:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 13:51 bug#42392: GCC includes ordering issue? g++: error: 'round' is not a member of 'std' maxim.cournoyer
2020-07-21 15:27 ` Ludovic Courtès [this message]
2020-07-23  9:37   ` Ludovic Courtès
2020-07-24 12:24     ` Ludovic Courtès
2020-07-26  5:33   ` Maxim Cournoyer
2020-07-27 18:24     ` Ludovic Courtès

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87imegoplx.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=42392@debbugs.gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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