草庐IT

fcatch-undefined-behavior

全部标签

c++ - 嵌套类显式特化 : different compiler behavior

以下代码compilesfinewithclang++6.0.0andg++7.3.0(compilationflagsare-std=c++14-Wall-Wextra-Werror-pedantic-errors)butfailstocompilewithvc++19.10.25017(compilationflagis/Za):templatestructA{templatestructB{};};templatetemplatestructA::B{staticvoidfoo();};voidA::B::foo(){}intmain(){}vc++编译错误信息:errorC29

c++ - 命名空间与类模板名称冲突 : different compiler behavior

不同的编译器showdifferentbehavior编译以下代码:namespaceN{namespaceFoo{templatestructFoo{};}}templateusingFoo=N::Foo::Foo;namespaceN{templatestructBar:Foo{};}intmain(){}测试的编译器及其编译标志:clang++5.0.0:-std=c++14-Wall-Wextra-Werror-pedantic-errorsg++7.2:-std=c++14-Wall-Wextra-Werror-pedantic-errorsvc++19.10.25017(V

c++ - 链接器错误:对 `std::ctype<char>::_M_widen_init() 的 undefined reference

我在尝试运行示例项目时遇到链接器错误。你能告诉我如何解决这个问题吗?提前致谢。make[1]:Enteringdirectory`/home/rumi/MobiusProject/Multiproc-Paper/Transformer/ssg'/usr/bin/g++-w-DMOBIUS_LITTLE_ENDIAN-DMOBIUS_LINUX-m32-ossgGen_Linux-L../../lib/Linux_lib/-L/home/rumi/Mobius/mobius/Mobius-2.3/Cpp/lib/Linux_lib-L/home/rumi/Mobius/mobius/Mo

c++ - glfw3 编译 undefined reference

我在编译使用glfw3库的程序时遇到问题。尝试使用make进行编译时,我得到了undefinedreference的错误列表,但我的类被编译成.o文件,只有最终的可执行文件没有创建。标准输出:g++-Wall-g-cmain.cpp-lGL-lGLU-lglfw3-lX11-lXxf86vm-lXrandr-lpthread-lXig++-Wall-g-cerror.cpp-lGL-lGLU-lglfw3-lX11-lXxf86vm-lXrandr-lpthread-lXig++-Wall-g-csWindow.cpp-lGL-lGLU-lglfw3-lX11-lXxf86vm-lXr

c++ - 表达式f()>g()的值,当f&g修改同一个全局变量undefined或unspecified时?

更新:根据用户ecatmur的标记,它是InC99,isf()+g()undefinedormerelyunspecified?的拷贝(尽管问题询问的是C99,但C++的答案不变)。答案是:未指定(对于这两种情况)。考虑以下C++14代码片段:inti=0;intx(){i++;returni;}inty(){i++;returni;}boolz=(x()>y());//unspecifiedorundefined?z的值只是未指定,还是未定义的行为?根据我的理解(如果我错了请更正),这样的表达式:i++>i++将是未定义的行为,因为我们在一对序列点之间对同一个变量进行两次变异,但是上

c++ - undefined reference ,在 64 位系统的 Ubuntu 上使用 FFMpeg-library (AvCodec)

我正在运行最新的FFMpeg库的示例代码。我已将示例代码插入到文件videofecencoder.c中:/**copyright(c)2001FabriceBellard**ThisfileispartofLibav.**Libavisfreesoftware;youcanredistributeitand/or*modifyitunderthetermsoftheGNULesserGeneralPublic*LicenseaspublishedbytheFreeSoftwareFoundation;either*version2.1oftheLicense,or(atyouropti

c++ - 表达式的行为 : Defined or Undefined?

我有以下代码intm[4]={1,2,3,4},*y;y=m;*y=f(y++);//ExpressionA我的friend告诉我,表达式A具有明确定义的行为,但我不确定他是否正确。根据他的说法,函数f()在两者之间引入了一个sequencepoint,因此行为定义明确。有人请澄清。P.S:我知道我们不应该出于实际目的编写这样的代码。这只是为了学习。:) 最佳答案 充其量,相关代码具有未指定的行为。对于赋值运算符,“操作数的求值顺序未指定”(C99§6.5.16/4)。如果先计算左操作数,则f(y++)的结果将存储在m[0]中。如果

c++ - 对符号的 undefined reference ,即使库已链接

链接我正在处理的项目时,链接器出现以下错误:/usr/bin/ld:../IncludesandLibs/lib/libsfml21rca.a(SoundFile.o):undefinedreferencetosymbol'sf_read_short@@libsndfile.so.1.0'/usr/bin/ld:note:'sf_read_short@@libsndfile.so.1.0'isdefinedinDSO/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libsndfile.sosotryaddingittoth

c++ - 对 boost::timer::auto_cpu_timer 的 undefined reference

我尝试使用g++4.4在Debian的远程服务器上使用boost库编译小型.cpp文件。为此,我使用Netbeans。我的家用机器在Windows7上。解决了一些链接下一个代码的问题后#include#include#includeintmain(){boost::timer::auto_cpu_timerac;//line5return0;//line6}产生2个错误:第5行:对boost::timer::auto_cpu_timer::auto_cpu_timer(short)'的undefinedreference第6行:对boost::timer::auto_cpu_timer

c++ - "undefined reference"到从静态方法访问的模板类的静态成员

我有一个静态类方法需要访问一个指针MyTypePointer,因此必须将其声明为静态。因为它是一个模板类,所以我必须将方法放在头文件中,但我不能在头文件中定义MyTypePointer。因此,由于未声明MyTypePointer,我得到了“undefinedReference”错误。我怎样才能使这项工作/声明MyTypePointer。myclass.htemplateclassPathfindingClass{typedefstd::vector*>MyType;staticMyType*MyTypePointer;};templatevoidMyClass::MyMethod(in