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

            Bug ID: 102782
           Summary: Including <cmath> causes ICE (illegal instruction in
                    min() and max()) on Haswell or older
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael_greenburg at byu dot edu
  Target Milestone: ---

Created attachment 51611
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51611&action=edit
Preprocessed source

When I compile the program:

```
#include <cmath>
int main() { return 0; }
```

with g++ 11.2.0 on RHEL 7.9, I get the following error on a Sandybridge node:

```
$ g++ -std=c++20 e.cc
In file included from /zapps7/gcc/11.2.0/include/c++/11.2.0/bits/specfun.h:46,
                 from /zapps7/gcc/11.2.0/include/c++/11.2.0/cmath:1927,
                 from e.cc:1:
/zapps7/gcc/11.2.0/include/c++/11.2.0/limits:1673:7: internal compiler error:
Illegal instruction
 1673 |       min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; }
      |       ^~~
0xcaa3af crash_signal
        /apps/src/gcc/src/gcc-11.2.0/gcc/toplev.c:327
0x7fb2c3eea4ae parsed_string_to_mpfr
        /apps/src/mpfr/src/mpfr-4.1.0/src/strtofr.c:551
0x7fb2c3eeb42f mpfr_strtofr
        /apps/src/mpfr/src/mpfr-4.1.0/src/strtofr.c:958
0xc1cae5 real_from_string(real_value*, char const*)
        /apps/src/gcc/src/gcc-11.2.0/gcc/real.c:2110
0xc1d50c real_from_string3(real_value*, char const*, format_helper)
        /apps/src/gcc/src/gcc-11.2.0/gcc/real.c:2176
0x841bc1 interpret_float
        /apps/src/gcc/src/gcc-11.2.0/gcc/c-family/c-lex.c:1018
0x84306b c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int)
        /apps/src/gcc/src/gcc-11.2.0/gcc/c-family/c-lex.c:504
0x735e76 cp_lexer_get_preprocessor_token
        /apps/src/gcc/src/gcc-11.2.0/gcc/cp/parser.c:864
0x77b400 cp_lexer_new_main
        /apps/src/gcc/src/gcc-11.2.0/gcc/cp/parser.c:663
0x77b400 c_parse_file()
        /apps/src/gcc/src/gcc-11.2.0/gcc/cp/parser.c:45317
0x84b46d c_common_parse_file()
        /apps/src/gcc/src/gcc-11.2.0/gcc/c-family/c-opts.c:1218
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

When I try to compile on a Haswell node it also fails (with a slightly
different error):

```
$ g++ -std=c++20 e.cc
In file included from /zapps7/gcc/11.2.0/include/c++/11.2.0/bits/specfun.h:46,
                 from /zapps7/gcc/11.2.0/include/c++/11.2.0/cmath:1927,
                 from optimize.cc:1:
/zapps7/gcc/11.2.0/include/c++/11.2.0/limits:1676:7: internal compiler error:
Illegal instruction
 1676 |       max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
      |       ^~~
0xcaa3af crash_signal
        /apps/src/gcc/src/gcc-11.2.0/gcc/toplev.c:327
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

...but compilation succeeds on Broadwell and Cascade Lake nodes.

The preprocessed file (from the compilation attempt on the Sandybridge node) is
attached.

Hardware: fails on Sandybridge (Xeon E5-2660), Haswell (Xeon E5-2670); succeeds
on Broadwell (Xeon E5-2680) and Cascade Lake (Xeon Gold 6230).

How GCC was configured: /apps/src/gcc/src/gcc-11.2.0/configure
--prefix=/apps/gcc/11.2.0 --enable-multiarch --disable-multilib
--enable-threads --with-fpmath=avx --enable-__cxa_atexit
--enable-languages=c,c++,fortran,lto --enable-valgrind-annotation
--with-arch=sandybridge --with-tune=broadwell --with-diagnostics-color=auto
--with-gmp=/apps/gmp/6.2.1 --with-mpfr=/apps/mpfr/4.1.0
--with-mpc=/apps/mpc/1.2.1

Reply via email to