clang++

clang memory sanitizer; how to make it print source line numbers

谁说我不能喝 提交于 2019-12-12 07:33:00
问题 I'm compiling my program with clang++ -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O0 and when I run it, the output is: matiu@matiu-laptop:~/projects/json++11/build$ ./tests .......==10534== WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7fe7602d4a51 (/home/matiu/projects/json++11/build/tests+0x106a51) #1 0x7fe7602dfca6 (/home/matiu/projects/json++11/build/tests+0x111ca6) ... #31 0x7fe75edbaec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4) #32

Misaligned address using virtual inheritance

女生的网名这么多〃 提交于 2019-12-12 07:15:42
问题 The following apparently valid code produces a misaligned address runtime error using the UndefinedBehaviorSanitizer sanitiser. #include <memory> #include <functional> struct A{ std::function<void()> data; // seems to occur only if data is a std::function } ; struct B{ char data; // occurs only if B contains a member variable }; struct C:public virtual A,public B{ }; struct D:public virtual C{ }; void test(){ std::make_shared<D>(); } int main(){ test(); return 0; } Compiling and executing on

clang++ (version 5) and LNK4217 warning

元气小坏坏 提交于 2019-12-12 07:11:06
问题 I am just learning how to code. I have installed clang version 5 on a windows 10 system using visual studio 14. I created a hello world cpp file to test that is working. Sample code #include <iostream> using namespace std; int main() { cout << "Hello World!\n"; int rip{1}; int dal{4}; int kane = rip + dal; cout << kane; return 0; } command clang++ -o .\bin\testing.exe test.cpp Clang does compile and I get an executable which does run as expected. however I do receive this message. test-3e53b3

Address sanitizer failure

心已入冬 提交于 2019-12-12 04:56:33
问题 I'm using gcc and clang-embedded sanitizers for a little, including address sanitizer. And things work pretty well, but on next demo code I get no output related to a error despite it is there (to be more precise -- no output at all): #include <string> #include <iostream> using std::string; using std::cout; class Foo { string _member; public: Foo(): _member("just a string") {} const string& get() const { return _member; } }; const string& bar() { // returning reference to a temp object on

How to fix clang libc++ error on Mac: calling private constructor

青春壹個敷衍的年華 提交于 2019-12-12 04:53:21
问题 I'm trying to compile a (private) C++ software with Clang and libc++ on Mac OS X 10.10 and am getting this error: error: calling a private constructor of class 'std::__1::__wrap_iter<unsigned short *>' Full error message here. Can someone explain this error and how to fix it? A small self-contained code example that results in this error and an option how to re-write it so that it works would be great! 回答1: You're asking for a self-contained example showing the error but haven't provided your

Is any way to get llvm deference pointer value's raw type(i.e. pointer type)

跟風遠走 提交于 2019-12-12 04:48:41
问题 Maybe the title is somehow confused. but let me show you a example. void foo(int val) { // do something } int i = 27; int* pi = &i; foo(*pi); Here, if we compile it using clang, the type of *pi will be i32, but we know pi is pointer type. my question is we use Function::getgetFunctionParamType method, the result will be i32. but how do I use some wayst to get ' pi ' type, not ' *pi ' type? This problem has confused me some days. Update: I see some people confused this question. Alright, I

Undefined reference with -static?

别等时光非礼了梦想. 提交于 2019-12-12 04:17:05
问题 When I try to compile my program with CFLAGS = -static i receive an error undefined reference. When compiling without static works perfectly. My question is why the static error gives me undefined reference? I installed with pkg install mysql57-server And linked mysql_config --libs Help ? 回答1: When linking static libs, the order in which they come in command line matters (well, at least on FreeBSD). Try putting -lmysqlclient before/after all libraries. And make sure there is /usr/local/lib

How to use LLVM's libcxx & libcxxabi in cmake project?

别等时光非礼了梦想. 提交于 2019-12-11 17:54:29
问题 Currently I'm running Debian stretch with the system's default compiler GCC 6.3.0. But I have a project using cmake (ceph's master branch) that depends on C++17, which requires non default includes and libraries. So I decided to use Clang/LLVM to build it. I downloaded and installed Clang/LLVM, compiled it and installed it below /usr/local . Now my question is, how to instruct cmake to use the includes from /usr/local/include/c++/v1/ and the libraries from /usr/local/lib ? 来源: https:/

temporary objects with variadic template arguments; another g++/clang++ difference

徘徊边缘 提交于 2019-12-11 13:33:28
问题 The following code struct foo { foo () { } template <typename T0, typename ... Ts> foo (const T0 & t0, const Ts & ... ts) { foo(ts...); } }; int main() { foo f(1, 2); return 0; } compile without problems with g++ (4.9.2) and give the following errors tmp_002-11,14,gcc,clang.cpp:9:16: error: expected ')' { foo(ts...); } ^ tmp_002-11,14,gcc,clang.cpp:9:13: note: to match this '(' { foo(ts...); } ^ tmp_002-11,14,gcc,clang.cpp:9:14: error: redefinition of 'ts' { foo(ts...); } ^ tmp_002-11,14,gcc

C++ template that used to work in old gcc results in 'shadows template parameter' error in clang++

放肆的年华 提交于 2019-12-11 12:48:04
问题 I wrote this code circa '08 using gcc 3.x. I'm now trying to compile with clang 3.4 and I'm getting a template error that I don't understand. The idea is to declare fixed-dimension vec types of arbitrary dimension and precision, and then define vecPair types based on those. I do not understand how the usage of the template typename S inside of "a.convert()" is shadowing the template parameter; it is meant to use the parameter, not redeclare it. Any information would be greatly appreciated!