草庐IT

clang-omp

全部标签

c++ - noexcept 说明符神秘地破坏了编译(clang,gcc 不同意)

有问题的代码是#include#includetemplatevoidfor_each(F&&)noexcept{}templatevoidfor_each(F&&f,T&&v,Us&&...us){std::invoke(std::forward(f),std::forward(v));for_each(std::forward(f),std::forward(us)...);}voidfunc(void*)noexcept{}intmain(){for_each(func,nullptr);}它在gcc8上编译,但在clang6上失败并出现以下错误:/opt/wandbox/cla

c++ - 忽略 clang-tidy 中的系统头文件

tldr;>如何在clang-tidy中隐藏来自系统header的警告?我有以下最小示例源文件,它会在系统header中触发一个整洁的警告:#includeintmain(){std::promisep;p.set_value(3);}在Ubuntu17.04上使用clang-tidy4.0.0使用libstdc++7.0.1调用它:$clang-tidymain.cpp-extra-arg=-std=c++14产量Runningwithoutflags.1warninggenerated./usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../

c++ - 哪个是更专业的模板功能? clang 和 g++ 对此有所不同

在使用可变参数模板时,跟随thisSOquestion(注意:不是必须去那里回答这个问题),对于以下模板重载函数,我遇到了clang(3.8)和g++(6.1)的不同行为:templatestructpack{};templateconstexprboolstarts_with(a,b){returnfalse;}templateclassPACK_A,templateclassPACK_B,typename...Ts1,typename...Ts2>constexprboolstarts_with(PACK_A,PACK_B){returntrue;}intmain(){std::c

c++ - 为什么clang不能启用所有的 sanitizer ?

Clang有各种sanitizer,可以打开以在运行时发现问题。但是,有些sanitizer我不能一起使用。这是为什么?clang++-3.9-std=c++1z-g-fsanitize=memory-fsanitize=address-omainmain.cpp1clang:error:invalidargument'-fsanitize=address'notallowedwith'-fsanitize=memory'这没什么大不了的,但是当我运行我的单元测试时,它花费的时间比它应该的要长,因为我为相同的测试创建了多个二进制文件,并分别运行它们中的每一个。clang++-3.9-s

c++ - CMake添加目标以调用clang分析器

我基本上希望达到与http://blog.alexrp.com/2013/09/26/clangs-static-analyzer-and-automake相同的效果,但使用CMake。analyze_srcs=foo.canalyze_plists=$(analyze_srcs:%.c=%.plist)CLEANFILES=$(analyze_plists)$(analyze_plists):%.plist:%.c@echo"CCSA"$@@$(COMPILE)--analyze$这样你就可以运行了makeanalyzemakeclean我想我需要使用add_custom_comma

c++ - GCC 和 Clang 不同意 C++17 constexpr lambda 捕获

考虑这个例子,它将一个变量声明为constexpr,通过在lambda中复制来捕获它,并声明另一个constexpr变量,该变量是constexpr函数从原始变量中解包非类型模板参数的结果。#includetemplateconstexprautounwrap(std::integral_constant){returnI;}intmain(){constexprautoi=std::integral_constant{};constexprautol=[i](){constexprintx=unwrap(i);};}Clang(主干)接受此代码。(wandbox)GCC(trunk)

c++ - 不能在函数中声明运算符。 Clang错误或规范?

C的一个奇怪的极端情况是函数可以在其他函数中声明,例如voidfoo(void){voidbar(void);//Behavesasifthiswaswrittenabovevoidfoo(void)bar();}这已经贯彻到C++中,至少对于大多数函数而言。如果有问题的函数恰好被称为operator==,则Clang似乎无法识别该模式。structfoo{intvalue;};structbar{foovalue;};boolwot(constbar&x,constbar&y){booleq(constfoo&,constfoo&);//Declarefunctioneqboolop

c++ - 使用 CRTP 时 clang++ 不接受使用模板模板参数

在使用带有CRTP的模板模板参数时,尝试在派生初始化列表中调用基类构造函数时遇到编译错误。可以用这段代码复制问题:templateclassDerived,classT>structbase{};templatestructderived:publicbase{derived():base(){}};有问题的错误消息:bug.cpp:10:16:error:templateargumentfortemplatetemplateparametermustbeaclasstemplateortypealiastemplate:base()^bug.cpp:10:11:error:expec

c++ - g++编译错误 "... is protected from within this context",而clang没有错误

我有以下代码:#includeclassBaseClass{protected:staticintx;};intBaseClass::x;classDerivedA:publicBaseClass{public:DerivedA(){x=3;}};classDerivedB:publicBaseClass{public:DerivedB(){std::cout使用g++编译(g++classtest.cpp)我收到以下错误:classtest.cpp:Inconstructor‘DerivedB::DerivedB()’:classtest.cpp:9:5:error:‘intBase

c++ - 带有 using-declarations 链接的程序在 MSVS 和 clang 上编译,但在 GCC 上不编译

根据c++标准,以下程序是良构的还是良构的?namespaceX{inti;}namespaceY{usingX::i;}intmain(){usingX::i;usingY::i;}我使用不同的编译器得到不同的结果:MSVS:编译(http://webcompiler.cloudapp.net/)Clang:编译(http://melpon.org/wandbox/permlink/KloDufJ5h1DalK4v)GCC:编译错误(http://melpon.org/wandbox/permlink/IKuuQGE1THofuUTr)我不想修复这个程序以使其在GCC上编译。我只想知