草庐IT

CLANG_ARGS

全部标签

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上编译。我只想知

c++ - 这是一个clang错误还是我不了解C++的东西?

在查看this时问题我用clang试了一下,遇到了一个奇怪的情况。下面的例子:#includeclassACP{public:ACP(){}operatorconststd::string()const{returnstd::string();}//operatorstd::string()const{returnstd::string();}在coliru上编译良好使用gcc,但使用clang失败。至少我认为这个例子没有问题-这是clang中的一个错误,还是有一个规则可以实际解释clang错误并且gcc是错误的?clang的错误如下所示:clang-std=c++14-O2-Wall

c++ - Clang 的 -Wall 和 -Wextra 中包含哪些警告?

我发现Clang的文档很差。我还没有找到很多可用的Clang警告标志列表。我对C/C++警告特别感兴趣,但这是一个普遍的问题。GCC在此处列出并描述了警告,还列出了-Wall和-Wextra中包含的内容:https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-OptionsClang的-Wall和-Wextra包含哪些警告标志?我可以搜索每个版本的Clang发行说明,看看每次引入了哪些新的警告标志(例如http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNote