clang++

LLDB not showing source code

混江龙づ霸主 提交于 2019-11-27 20:39:01
I am trying to debug a C++ program I am writing, but when I run it in LLDB and stop the program, it only shows me the assembler, not the original source. e.g. after the crash I’m trying to debug: Process 86122 stopped * thread #13: tid = 0x142181, 0x0000000100006ec1 debug_build`game::update() + 10961, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) frame #0: 0x0000000100006ec1 debug_build`game::update() + 10961 debug_build`game::update: -> 0x100006ec1 <+10961>: movq (%rdx), %rdx 0x100006ec4 <+10964>: movq %rax, -0xb28(%rbp) 0x100006ecb <+10971>: movq -0x1130(%rbp), %rax 0x100006ed2 <+10978>

What is the supposed behavior of copy-list-initialization in the case of an initializer with a conversion operator?

眉间皱痕 提交于 2019-11-27 16:29:44
问题 class AAA { public: AAA() {} AAA(const AAA&) {} }; class BBB { public: BBB() {} operator AAA() { AAA a; return a; } }; int main() { BBB b; AAA a = {b}; } The above code compiles on g++ and vc++, but not clang++. The traditional syntax AAA a = b; compiles ok on all three. class AAA {}; class BBB { public: BBB() {} operator AAA() { AAA a; return a; } }; int main() { BBB b; AAA a = {b}; } The above code doesn't compile on any of g++, vc++, clang++. The only difference against the first code

Is it safe to create a const reference to result of ternary operator in C++?

跟風遠走 提交于 2019-11-27 14:42:48
问题 There's something quite non-obvious going on in this code: float a = 1.; const float & x = true ? a : 2.; // Note: `2.` is a double a = 4.; std::cout << a << ", " << x; both clang and gcc output: 4, 1 One would naively expect the same value printed twice but this isn't the case. The issue here has nothing to do with the reference. There are some interesting rules dictating the type of ? : . If the two arguments are of different type and can be casted, they will by using a temporary. The

C++ linking error after upgrading to Mac OS X 10.9 / Xcode 5.0.1

血红的双手。 提交于 2019-11-27 11:08:24
After upgrading to Mac OS X 10.9 / Xcode 5.0.1, command lines to create a shared library (.dylib) failed with several undefined symbols. clang++ -dynamiclib -install_name test.dylib *.o -o test.dylib Undefined symbols for architecture x86_64: "std::allocator<char>::allocator()", referenced from: _main in test.o "std::allocator<char>::~allocator()", referenced from: _main in test.o "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from: _main in test.o "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char>

Different compiler behavior for expression: auto p {make_pointer()};

馋奶兔 提交于 2019-11-27 09:25:44
Which is the correct behaviour for the following program? // example.cpp #include <iostream> #include <memory> struct Foo { void Bar() const { std::cout << "Foo::Bar()" << std::endl; } }; std::shared_ptr<Foo> MakeFoo() { return std::make_shared<Foo>(); } int main() { auto p { MakeFoo() }; p->Bar(); } When I compile it in my Linux RHEL 6.6 workstation, I obtain the following results: $ g++ -v gcc version 5.1.0 (GCC) $ g++ example.cpp -std=c++14 -Wall -Wextra -pedantic $ ./a.out Foo::Bar() but $ clang++ -v clang version 3.6.0 (trunk 217965) $ clang++ example.cpp -std=c++14 -Wall -Wextra

Template Argument Deduction Broken in Clang 6 for Temporary Objects

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 07:44:52
问题 Template argument deduction appears to be broken in Clang 6 for temporary objects. g++ 8.1.0 compiles and runs the example correctly. Clang 6.0.0 and 6.0.2 both error at the indicated line with this message: error: expected unqualified-id Print{1,"foo"s,2}; /********** Broken in Clang **********/ All Other lines work correctly. The behavior is the same in both cases whether -std=c++17 or -std=c++2a is used. The Clang c++ Status Page indicates that template argument deduction was implemented

Using memory sanitizer with libstdc++

◇◆丶佛笑我妖孽 提交于 2019-11-27 02:38:10
问题 I wish to use the -fsanitize=memory flag in clang to analyse a program like the following: #include <string> #include <iostream> #include <fstream> using namespace std; void writeToFile(){ ofstream o; o.open("dum"); o<<"test"<<endl; //The error is here. //It does not matter if the file is opened this way, //or with o("dum"); o.close(); } int main(){ writeToFile(); } As far as I know, this program is correct, but when I use clang++ san.cpp -fsanitize=memory It fails (at runtime) with: UMR in _

linking with clang++ on OS X generates lots of symbol not found errors

纵然是瞬间 提交于 2019-11-27 01:25:21
I'm trying to compile some C++ code (including C++11 features) on OS X 10.8 using the clang++ compiler. I have a makefile that generates the object files OK, then on the command: clang++ -o Analysis.so -shared DataFile.o CR39DataFile.o I get tons of errors about symbol(s) not found for architecture x86_64. The code works fine on a *nix system using g++ and changing the compiler flags appropriately for C++11 support. To compile the *.o I am doing it like: clang++ -c -Wall -std=c++11 -stdlib=libc++ -I../src ../src/DataFile.cc Edit: output of the linking command is: clang++ -o Analysis.so -shared

Simple std::regex_search() code won't compile with Apple clang++ -std=c++14

混江龙づ霸主 提交于 2019-11-26 23:34:49
问题 Here is the MCVE: #include <iostream> #include <regex> std::string s() { return "test"; } int main() { static const std::regex regex(R"(\w)"); std::smatch smatch; if (std::regex_search(s(), smatch, regex)) { std::cout << smatch[0] << std::endl; } return 0; } It compiles fine with: $ clang++ -std=c++11 main.cpp but not with: $ clang++ -std=c++14 main.cpp Error message in the later case (with -std=c++14): main.cpp:14:9: error: call to deleted function 'regex_search' if (std::regex_search(s(),

How is P0522R0 breaking code?

萝らか妹 提交于 2019-11-26 23:26:51
问题 Today I was reading the C++17 support page of clang. I've notice something odd. The feature Matching template template parameters to compatible arguments (P0522R0) is marked as partial, because it must be activate through a switch. Their note says: Despite being the the resolution to a Defect Report, this feature is disabled by default in all language versions, and can be enabled explicitly with the flag -frelaxed-template-template-args in Clang 4. The change to the standard lacks a