Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ G++;将float视为非法指令_C++_Gcc_Floating Point_G++_Gnu - Fatal编程技术网

C++ G++;将float视为非法指令

C++ G++;将float视为非法指令,c++,gcc,floating-point,g++,gnu,C++,Gcc,Floating Point,G++,Gnu,在我的文件“six.cpp”中,我试图打印一个浮点,但编译器不断抛出一个错误。以下是文件“six.cpp”: 我刚开始用C++编程,我很困惑为什么会这样。我也做了一些谷歌搜索,但没有找到任何相关信息。您有一个内部编译器错误:非法指令,这意味着gcc编译器本身失败。从警告中可以看出,您似乎错误安装了gcc工具链。尝试删除它并重新安装或升级。源代码中失败的部分在这里并不特别有趣,重要的是“内部编译器错误:非法指令” 这意味着您的g++副本是为比您运行它的CPU更新的子体系结构而构建的。例如,SSE4

在我的文件“six.cpp”中,我试图打印一个浮点,但编译器不断抛出一个错误。以下是文件“six.cpp”:


我刚开始用C++编程,我很困惑为什么会这样。我也做了一些谷歌搜索,但没有找到任何相关信息。

您有一个
内部编译器错误:非法指令
,这意味着
gcc
编译器本身失败。从警告中可以看出,您似乎错误安装了
gcc
工具链。尝试删除它并重新安装或升级。

源代码中失败的部分在这里并不特别有趣,重要的是“内部编译器错误:非法指令”

这意味着您的g++副本是为比您运行它的CPU更新的子体系结构而构建的。例如,SSE4指令是在2006年引入的,旧的CPU设计不支持它们。由于SSE用于浮点计算,查找浮点文本触发错误是有道理的,但根本原因是指令集不匹配

如果选中
/proc/cpuinfo
,您可以找到CPU上支持哪些指令集扩展,这将帮助您选择正确的g++构建选项(无论您是自行构建还是下载使用这些选项构建的包)


相关选项尤其是
-march=
-mfpmath=
,以及
-m(no)熔融madd

1。为什么您的代码链接到GMP和MPFR?抱歉,这些是多精度库,我看不出你在哪里需要它们。2.显然,GMP和MPFR的标题与库不匹配。3.您似乎遇到了内部编译器错误。可能是您的设置有问题。删除所有内容并正确安装匹配的cygwin。@鲁迪:GNU编译器集合在内部使用这些内容。@BenVoigt:好的,我不知道。谢谢你的提醒。
#include <iostream>
#include <iomanip>
using namespace std;

int main(){
  double f = 5.3;
  cout << f << endl;
  return 0;
}
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-4.9.3-1.x86_64/src/gcc-4.9.3/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-4.9.3-1.x86_64/src/gcc-4.9.3 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libgcj-sublibs --disable-java-awt --disable-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id
Thread model: posix
gcc version 4.9.3 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/cc1plus.exe -quiet -v -Dunix -idirafter /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../lib/../include/w32api -idirafter /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/lib/../lib/../../include/w32api six.cpp -quiet -dumpbase six.cpp -mtune=generic -march=x86-64 -auxbase six -version -o /tmp/ccfHbtlL.s
GNU C++ (GCC) version 4.9.3 (x86_64-pc-cygwin)
        compiled by GNU C version 4.9.3, GMP version 6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.3
warning: GMP header version 6.0.0 differs from library version 6.1.0.
warning: MPFR header version 3.1.2-p11 differs from library version 3.1.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/include"
ignoring duplicate directory "/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/lib/../lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++
 /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++/x86_64-pc-cygwin
 /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/c++/backward
 /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include
 /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include-fixed
 /usr/include
 /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../lib/../include/w32api
End of search list.
GNU C++ (GCC) version 4.9.3 (x86_64-pc-cygwin)
        compiled by GNU C version 4.9.3, GMP version 6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.3
warning: GMP header version 6.0.0 differs from library version 6.1.0.
warning: MPFR header version 3.1.2-p11 differs from library version 3.1.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a7b6fac296390f5db29d753ab65194e7
six.cpp:6:3: internal compiler error: Illegal instruction
   double f = 5.3;
   ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.