clang++

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

你离开我真会死。 提交于 2019-11-26 17:49:55
问题 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

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

倖福魔咒の 提交于 2019-11-26 15:26:13
问题 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

clang: no out-of-line virtual method definitions (pure abstract C++ class)

孤街浪徒 提交于 2019-11-26 10:35:39
问题 I\'m trying to compile the following simple C++ code using Clang-3.5: test.h: class A { public: A(); virtual ~A() = 0; }; test.cc: #include \"test.h\" A::A() {;} A::~A() {;} The command that I use for compiling this (Linux, uname -r: 3.16.0-4-amd64): $clang-3.5 -Weverything -std=c++11 -c test.cc And the error that I get: ./test.h:1:7: warning: \'A\' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Wweak-vtables] Any hints why this is