clang++

the purpose of the -Wlifetime flag?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 17:38:39
问题 What is the purpose of the -Wlifetime compile flag in clang ? The information I found on the Internet about it are very vague. Is this any noticeable feature? 回答1: This flag analyzes the local file to see if the code may use pointers to objects that are dead. You can see Herb Sutter cppcon video on YouTube where he explains this very well: https://youtu.be/80BZxujhY38 来源: https://stackoverflow.com/questions/52662135/the-purpose-of-the-wlifetime-flag

Is clang's c++11 support reliable?

此生再无相见时 提交于 2019-12-21 12:42:56
问题 I ran into an interesting issue when trying to mix clang (Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn, Target: x86_64-apple-darwin14.0.0), c++11 and CGAL (via MacPorts). It seems that whether or not I call std::vector<>::reserve will determine whether my program will even compile. I've trimmed down the problem into a minimal example (as minimal as CGAL examples get): #include <vector> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/AABB_tree.h>

Is clang's c++11 support reliable?

江枫思渺然 提交于 2019-12-21 12:41:50
问题 I ran into an interesting issue when trying to mix clang (Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn, Target: x86_64-apple-darwin14.0.0), c++11 and CGAL (via MacPorts). It seems that whether or not I call std::vector<>::reserve will determine whether my program will even compile. I've trimmed down the problem into a minimal example (as minimal as CGAL examples get): #include <vector> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/AABB_tree.h>

Clangs C++ Module TS support: How to tell clang++ where to find the module file?

核能气质少年 提交于 2019-12-21 12:38:48
问题 In his talk at CppCon, Richard Smith mentioned that even though the Module TS support is currently work in progress, it can already be used. So I build clang 4.0 from svn and tried it on a very simple example. In my myclass.cppm file I defined a simple wrapper for an int module myclass; export class MyClass { public: MyClass (int i) : _i{i} {} int get() { return _i; } private: int _i; }; and my main.cpp just creates one instance of that class and outputs its held int to std::cout . #include

How can I enable clang-tidy's “modernize” checks?

假如想象 提交于 2019-12-21 11:33:12
问题 I just installed ClangOnWin,and I'm trying to get clang-tidy 's "modernize" checks to work. Unfortunately, clang-tidy doesn't seem to know about them: clang-tidy -list-checks foo.cpp -- | grep modernize produces no output. The "modernize" checks are listed here, but that page seems to document Clang 3.8, and the version I have installed is 3.7. However, version 3.7 is the current one listed at the LLVM Download Page. clang-tidy knows about a variety of security checks, so I think I have it

clang++ fails but g++ succeeds on using a cast to const-unrelated-type operator in an assignment

≡放荡痞女 提交于 2019-12-21 09:21:42
问题 Here's a short example that reproduces this “no viable conversion” with lemon for clang but valid for g++ difference in compiler behavior. #include <iostream> struct A { int i; }; #ifndef UNSCREW_CLANG using cast_type = const A; #else using cast_type = A; #endif struct B { operator cast_type () const { return A{i}; } int i; }; int main () { A a{0}; B b{1}; #ifndef CLANG_WORKAROUND a = b; #else a = b.operator cast_type (); #endif std::cout << a.i << std::endl; return EXIT_SUCCESS; } live at

clang bug? namespaced template class' friend

南楼画角 提交于 2019-12-21 07:21:40
问题 The following code which doesn't compile under clang but does under gcc and VS: template<typename T> class bar; namespace NS { template<typename T> class foo { foo() {} template<typename U> friend class bar; }; } template<typename R> class bar { public: bar() { NS::foo<int> f; } }; int main(int, char **) { bar<int> b; return 0; } It fails with: main.cpp:20:22: error: calling a private constructor of class 'NS::foo<int>' NS::foo<int> f; ^ main.cpp:8:9: note: implicitly declared private here

clang bug? namespaced template class' friend

吃可爱长大的小学妹 提交于 2019-12-21 07:21:03
问题 The following code which doesn't compile under clang but does under gcc and VS: template<typename T> class bar; namespace NS { template<typename T> class foo { foo() {} template<typename U> friend class bar; }; } template<typename R> class bar { public: bar() { NS::foo<int> f; } }; int main(int, char **) { bar<int> b; return 0; } It fails with: main.cpp:20:22: error: calling a private constructor of class 'NS::foo<int>' NS::foo<int> f; ^ main.cpp:8:9: note: implicitly declared private here

lldb error: process launch failed: unable to locate lldb-server

♀尐吖头ヾ 提交于 2019-12-21 03:55:32
问题 I'm running Xubuntu 16.04. After installing lldb from the repositories, I get the following output when I try to use it: lldb foo (lldb) target create "foo" Current executable set to 'foo' (x86_64). (lldb) r error: process launch failed: unable to locate lldb-server Any ideas what I'm missing? 回答1: After an hour or so of fiddling around, I found the solution. I copied /usr/bin/lldb-server-3.8 and named it /usr/bin/lldb-server . This is probably a problem with the ubuntu package. 回答2: I

What is the difference? clang++ | clang -std=c++11

六眼飞鱼酱① 提交于 2019-12-20 08:40:02
问题 I had been erroneously using this command, which failed at the link step: $ clang -std=c++11 -stdlib=libc++ myInputFile.cpp Can anyone explain why clang provides a C++ language option, and why it fails to link? Why don't the options -x c++ or -std=c++11 accomplish the same thing as clang++ ? Thanks! 回答1: Technically, neither of the programs named clang or clang++ is a compiler: they are both drivers that analyze the input arguments and determine what compilers/assemblers/linkers to invoke on