如何解决g++问题"internal compiler error: Illegal instruction min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MI

How to solve the g++ problem "internal compiler error: Illegal instruction min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; }"?

本文关键字:GLIBCXX min instruction USE MI FLT return Illegal NOEXCEPT error g++      更新时间:2023-10-16

Ubuntugcc 8.3.0上,我编译test.cpp文件:

#include<algorithm>
int main(){}
g++ -o test test.cpp

并得到以下编译错误

In file included from /usr/include/c++/8/bits/uniform_int_dist.h:35,
from /usr/include/c++/8/bits/stl_algo.h:66,
from /usr/include/c++/8/algorithm:62,
from test.cpp:1:
/usr/include/c++/8/limits:1599:7: internal compiler error: Illegal instruction
min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; }
^~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.

问题可能是由<algorithm>引起的?经过尝试,当我使用c++98时,问题没有出现,例如:

g++ -o test test.cpp --std=c++98    //compiling succeed
g++ -o test test.cpp --std=c++11    //compiling fail

我已经重新安装了gcc,错误仍然存在。事实上,我有一个.cpp文件需要c++11,所以我想知道如何通过c++11编译包括<algorithm>在内的.cpp文件。

您的代码是正确的,这是一个GCC 8错误。这就是错误消息指向Readme.Bugs的原因。新的GCC 9有一个PPA。