clang++

Warning: definition of implicit copy constructor is deprecated

断了今生、忘了曾经 提交于 2019-11-30 13:54:47
问题 I have a warning in my C++11 code that I would like to fix correctly but I don't really know how. I have created my own exception class that is derived from std::runtime_error : class MyError : public std::runtime_error { public: MyError(const std::string& str, const std::string& message) : std::runtime_error(message), str_(str) { } virtual ~MyError() { } std::string getStr() const { return str_; } private: std::string str_; }; When I compile that code with clang-cl using /Wall I get the

Rcpp and default C++ compiler

浪子不回头ぞ 提交于 2019-11-30 13:12:48
I have some strange troubles with Rcpp - it uses unpredictable C++ compiler. This question is somewhat similar to this question . I'm on OSX, I have 2 complilers - default clang and clang-omp with openmp support. Also I have following ~/.R/Makevars file (where I set up clang-omp as default compiler): CC=clang-omp CXX=clang-omp++ CFLAGS += -O3 -Wall -pipe -pedantic -std=gnu99 CXXFLAGS += -O3 -Wall -pipe -Wno-unused -pedantic -fopenmp The problem is that, the package I'm developing compiles with clang++ , not clang-omp++ . I also tried (as experiment to lacate issue) to change package src

clang++ -stdlib=libc++ leads to undefined reference

痴心易碎 提交于 2019-11-30 13:10:31
Why am I getting the following linker error when using clang with libc++: $ clang++ -stdlib=libc++ po.cxx -lpoppler /tmp/po-QqlXGY.o: In function `main': po.cxx:(.text+0x33): undefined reference to `Dict::lookup(char*, Object*, std::__1::set<int, std::__1::less<int>, std::__1::allocator<int> >*)' clang: error: linker command failed with exit code 1 (use -v to see invocation) Where: $ nm -D /usr/lib/x86_64-linux-gnu/libpoppler.so | grep lookup | c++filt| grep \ Dict::lookup\( 00000000000c1870 T Dict::lookup(char*, Object*, std::set<int, std::less<int>, std::allocator<int> >*) Code is simply:

What is the LLVM version bundled with Xcode?

只谈情不闲聊 提交于 2019-11-30 12:36:48
Up to Xcode 6 when typing clang --version we got the information on what LLVM version it was built: Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) But now with Xcode 7 we only get the following: Apple LLVM version 7.0.0 (clang-700.0.72) See https://gist.github.com/yamaya/2924292 in which an interesting comment says: Looking at the sources (src/CMakeLists.txt), it appears AppleClang is based on (approximately) the following LLVM branches: clang-700.0.72 => LLVM 3.7.0 clang-700.1.76 => LLVM 3.7.0 clang-700.1.81 => LLVM 3.7.0 clang-703.0.29 => LLVM 3.8.0 clang-703.0.31 => LLVM

using vs. typedef - is there a subtle, lesser known difference?

有些话、适合烂在心里 提交于 2019-11-30 10:57:30
Background Everybody agrees that using <typedef-name> = <type>; is equivalent to typedef <type> <typedef-name>; and that the former is to be preferred to the latter for various reasons (see Scott Meyers, Effective Modern C++ and various related questions on stackoverflow). This is backed by [dcl.typedef]: A typedef-name can also be introduced by an alias-declaration. The identifier following the using keyword becomes a typedef-name and the optional attribute-specifier-seq following the identifier appertains to that typedef-name. Such a typedef-name has the same semantics as if it were

How do I detect if my code is being compiled with -fno-exceptions?

纵饮孤独 提交于 2019-11-30 09:10:18
I'm writing a C++ library and I would like to make my API throw exceptions for invalid parameters, but rely on asserts instead when the code is compiled with -fno-exceptions . Is there a way to detect at compile-time if I'm allowed to use exception handling? Note that I'm writing a header-only library, so I don't have a configure phase and I don't have access to the build system to simply define a macro on the command line (and I don't want to add burden to the user). Since the Standard doesn't have any concept of "-fno-exceptions", of course the solution could be compiler-dependent. In this

Standard-layout and tail padding

霸气de小男生 提交于 2019-11-30 08:10:14
David Hollman recently tweeted the following example (which I've slightly reduced): struct FooBeforeBase { double d; bool b[4]; }; struct FooBefore : FooBeforeBase { float value; }; static_assert(sizeof(FooBefore) > 16); //---------------------------------------------------- struct FooAfterBase { protected: double d; public: bool b[4]; }; struct FooAfter : FooAfterBase { float value; }; static_assert(sizeof(FooAfter) == 16); You can examine the layout in clang on godbolt and see that the reason the size changed is that in FooBefore , the member value is placed at offset 16 (maintaining a full

'auto' not allowed in function prototype with Clang

纵然是瞬间 提交于 2019-11-30 08:00:42
问题 Using Clang 3.5, 3.6, or 3.7, with the flag std=c++1y the following code does not compile : #include <iostream> auto foo(auto bar) { return bar; } int main() { std::cout << foo(5.0f) << std::endl; } The error given is : error: 'auto' not allowed in function prototype I do not have errors using g++ 4.9. Is this error produced because Clang has not yet implemented this functionnality yet or is it because I am not allowed to do that and GCC somehow permits it ? 回答1: As we see from the ISO C++

Member not zeroed, a clang++ bug?

前提是你 提交于 2019-11-30 06:56:54
问题 Consider the following code: class A { public: int i; A() {} }; class B { public: A a; int i; }; int main() { B* p = new B {}; std::cout << p->i << " " << p->a.i << "\n"; } Compiled with -std=c++11 in clang++, p->i turns out to be zero, but p->a.i doesn't. Shouldn't the whole object be zeroed as long as its class doesn't have user-provided constructor? EDIT: Since there are some extensive discussion in the comments, I think it's better to add some excerpt from the standard here: To value

Are C++17 Parallel Algorithms implemented already?

浪子不回头ぞ 提交于 2019-11-30 06:55:32
问题 I was trying to play around with the new parallel library features proposed in the C++17 standard, but I couldn't get it to work. I tried compiling with the up-to-date versions of g++ 8.1.1 and clang++-6.0 and -std=c++17 , but neither seemed to support #include <execution> , std::execution::par or anything similar. When looking at the cppreference for parallel algorithms there is a long list of algorithms, claiming Technical specification provides parallelized versions of the following 69