clang++

clang++ fstreams 10X slower than g++

只谈情不闲聊 提交于 2019-12-04 04:10:13
问题 Q: Is there a way to speed up clang++ STD Library fstreams? (And does anybody know why it is so much slower than g++?) I am trying to process very large (many GBs) binary data files and was surprised to find the performance was so poor. At first, I thought it was something to do with my code. But I am seeing the same slow performance in a boiled down example. I even tried allocating different size buffers via rdbuf()->pubsetbuf() but this didn't seem to have much effect. Here is a simple

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

喜夏-厌秋 提交于 2019-12-04 03:40:28
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 godbolt's g++ (4.9, 5.2) compiles that silently; whereas clang++ (3.5, 3.7) compiles it if using cast

Linking libc++ to CMake project on Linux

荒凉一梦 提交于 2019-12-04 03:00:16
I want to use libc++ together with clang on Arch Linux in CMake project. I installed libc++ and added following lines to CMakeLists.txt as said on LLVM site in Linux section of "Using libc++ in your programs": set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") set(CMAKE_EXE_LINKER_FLAGS "-lc++abi") I have tried just "++abi" in linker's flags, but it didn't help. I need some help in figuring out what i should write in my CMakeLists.txt. emw Don't forget to set the compiler to clang++: set(CMAKE_CXX_COMPILER "clang++") Also, purge the cmake generated files (delete the folder

clang bug? namespaced template class' friend

孤街醉人 提交于 2019-12-04 00:08:33
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 foo() {} ^ bar should have access to foo 's private constructor but it looks like it doesn't. If I remove

Why can't clang enable all sanitizers?

拜拜、爱过 提交于 2019-12-03 22:39:17
Clang has various sanitizers that can be turned on to catch problems at runtime. However, there are some sanitizers that I can't use together. Why is that? clang++-3.9 -std=c++1z -g -fsanitize=memory -fsanitize=address -o main main.cpp 1 clang: error: invalid argument '-fsanitize=address' not allowed with '-fsanitize=memory' It's not a big deal, but when I run my unit tests, it takes longer than it should, because I have create multiple binaries for the same tests, and run each of them separately. clang++-3.9 -std=c++1z -g -fsanitize=address -o test1 test.cpp clang++-3.9 -std=c++1z -g

How to force clang to use some library by default?

試著忘記壹切 提交于 2019-12-03 20:35:16
问题 I build clang by clang against libc++ , libc++abi , compiler-rt in the following steps: To download (and update) llvm and sub-projects I use the following script: svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm cd llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk clang/tools/extra svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb svn co http://llvm.org/svn/llvm-project/lld/trunk lld svn co http:/

XCode 9: “clang: error: cannot specify -o when generating multiple output files”

被刻印的时光 ゝ 提交于 2019-12-03 14:13:10
I've just updated xcode to version 9 and I've started getting the following error message when compiling: clang: error: cannot specify -o when generating multiple output files The issue seems to be linked to compiling with the "Optimization Level" parameter set to "None" (i.e. -O0). If I set this higher the error goes away, BUT when I increase the optimization the debugging tools do not work appropriately (for example variable tracking). I've looked at other questions that list this error, but they either involve some kind of duplicate '-isystem' or dont involve xcode at all. I'm currently

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

谁说我不能喝 提交于 2019-12-03 11:59:10
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? 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. I recommend setting an alternative rather than copying. On Ubuntu, you can do this with: sudo update-alternatives -

Forward declaration of class used in template function is not compiled by clang++

微笑、不失礼 提交于 2019-12-03 11:20:34
There is this code: class A; template <class T> void fun() { A a; } class A { public: A() { } }; int main() { fun<int>(); return 0; } g++ 4.5 and g++ 4.7 compiles this without error. But clang++ 3.2 (trunk) gives this error: main.cpp:5:6: error: variable has incomplete type 'A' A a; ^ main.cpp:1:7: note: forward declaration of 'A' class A; ^ Which compiler is right then according to C++ standard? Which compiler is right then according to C++ standard? Both are correct. This is an ill-formed program. Emphasis mine: N3290 14.6¶9 If a type used in a non-dependent name is incomplete at the point

Clang and GCC disagree in auto specifier for non-type template parameter in a casting C++17

六月ゝ 毕业季﹏ 提交于 2019-12-03 11:00:45
I basically have a class that depends on a non-type template parameter. I defined a casting so an object of non-type template parameter N can convert to another of M . I have a minimal example that can reproduce the situation: template<auto Integral> class Test{ public: typedef decltype(Integral) value_type; static constexpr value_type N = Integral; constexpr Test (const value_type& x = 0); template<auto Integral2> constexpr explicit operator Test<Integral2>() const; private: value_type n; }; template<auto Integral> constexpr Test<Integral>::Test (const value_type& x){ if (x < 0){ n = N - (-x)