users users via llvm-dev
2021-Feb-11 22:20 UTC
[llvm-dev] Clang++: No member name 'make_unique' in namespace 'std'
Dear LLVM Developers: 1. Recently I built llvm/12.0 on IBM power8 using gcc/8.2.0. When I run clang++ with an example from https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique: #include <iostream> #include <iomanip>#include <memory> struct Vec3{ int x, y, z; // following constructor is no longer needed since C++20 Vec3(int x = 0, int y = 0, int z = 0) noexcept : x(x), y(y), z(z) { } friend std::ostream <http://en.cppreference.com/w/cpp/io/basic_ostream>& operator<<(std::ostream <http://en.cppreference.com/w/cpp/io/basic_ostream>& os, const Vec3& v) { return os << "{ x=" << v.x << ", y=" << v.y << ", z=" << v.z << " }"; }}; int main(){ // Use the default constructor. std::unique_ptr <http://en.cppreference.com/w/cpp/memory/unique_ptr><Vec3> v1 std::make_unique<Vec3>(); // Use the constructor that matches these arguments std::unique_ptr <http://en.cppreference.com/w/cpp/memory/unique_ptr><Vec3> v2 std::make_unique<Vec3>(0,1,2); // Create a unique_ptr to an array of 5 elements std::unique_ptr <http://en.cppreference.com/w/cpp/memory/unique_ptr><Vec3[]> v3 std::make_unique<Vec3[]>(5); std::cout <http://en.cppreference.com/w/cpp/io/cout> << "make_unique<Vec3>(): " << *v1 << '\n' << "make_unique<Vec3>(0,1,2): " << *v2 << '\n' << "make_unique<Vec3[]>(5): "; for (int i = 0; i < 5; i++) { std::cout <http://en.cppreference.com/w/cpp/io/cout> << std::setw <http://en.cppreference.com/w/cpp/io/manip/setw>(i ? 30 : 0) << v3[i] << '\n'; }} It failed with the following errors: Error: no member named 'make_unique' in namespace 'std' std::unique_ptr<Vec3> v1 = std::make_unique<Vec3>(); ... ... Any idea and suggestion about what is going on? or have I missed something? The command I used to compile the code above: $ clang++ a.cpp 2. Comparing this llvm with my current gcc/8.2.0 on a project (openmp code running 1 thread), it showed that llvm is almost twice as slow as gcc (both compile with -O3) on my IBM power8 machine. Is it suppose to be with such slower performance than gcc? Thank you very much for any advice! Best Regards, Shelton -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210211/34485752/attachment.html>
David Blaikie via llvm-dev
2021-Feb-11 22:25 UTC
[llvm-dev] Clang++: No member name 'make_unique' in namespace 'std'
1) clang++ -v will show you which standard library headers it's using, it might be using an older standard library on your system that doesn't have std::make_unique. 2) Did you build the compiler in release mode, or in debug mode? (with or without assertions enabled) On Thu, Feb 11, 2021 at 2:21 PM users users via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Dear LLVM Developers: > > 1. Recently I built llvm/12.0 on IBM power8 using gcc/8.2.0. When I run clang++ with an example from https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique: > > #include <iostream> > > #include <iomanip> > #include <memory> > > struct Vec3 > { > int x, y, z; > > // following constructor is no longer needed since C++20 > Vec3(int x = 0, int y = 0, int z = 0) noexcept : x(x), y(y), z(z) { } > > friend std::ostream& operator<<(std::ostream& os, const Vec3& v) { > return os << "{ x=" << v.x << ", y=" << v.y << ", z=" << v.z << " }"; > } > }; > > int main() > { > // Use the default constructor. > std::unique_ptr<Vec3> v1 = std::make_unique<Vec3>(); > // Use the constructor that matches these arguments > std::unique_ptr<Vec3> v2 = std::make_unique<Vec3>(0,1,2); > // Create a unique_ptr to an array of 5 elements > std::unique_ptr<Vec3[]> v3 = std::make_unique<Vec3[]>(5); > > std::cout << "make_unique<Vec3>(): " << *v1 << '\n' > << "make_unique<Vec3>(0,1,2): " << *v2 << '\n' > << "make_unique<Vec3[]>(5): "; > for (int i = 0; i < 5; i++) { > std::cout << std::setw(i ? 30 : 0) << v3[i] << '\n'; > } > } > > > It failed with the following errors: > Error: no member named 'make_unique' in namespace 'std' > std::unique_ptr<Vec3> v1 = std::make_unique<Vec3>(); > ... ... > > Any idea and suggestion about what is going on? or have I missed something? The command I used to compile the code above: > $ clang++ a.cpp > > 2. Comparing this llvm with my current gcc/8.2.0 on a project (openmp code running 1 thread), it showed that llvm is almost twice as slow as gcc (both compile with -O3) on my IBM power8 machine. Is it suppose to be with such slower performance than gcc? > > Thank you very much for any advice! > > Best Regards, > Shelton > > > > > > > > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Mehdi AMINI via llvm-dev
2021-Feb-11 22:26 UTC
[llvm-dev] Clang++: No member name 'make_unique' in namespace 'std'
On Thu, Feb 11, 2021 at 2:21 PM users users via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Dear LLVM Developers: > > 1. Recently I built llvm/12.0 on IBM power8 using gcc/8.2.0. When I run > clang++ with an example from > https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique: > > #include <iostream> > > #include <iomanip>#include <memory> > struct Vec3{ > int x, y, z; > > // following constructor is no longer needed since C++20 > Vec3(int x = 0, int y = 0, int z = 0) noexcept : x(x), y(y), z(z) { } > > friend std::ostream <http://en.cppreference.com/w/cpp/io/basic_ostream>& operator<<(std::ostream <http://en.cppreference.com/w/cpp/io/basic_ostream>& os, const Vec3& v) { > return os << "{ x=" << v.x << ", y=" << v.y << ", z=" << v.z << " }"; > }}; > int main(){ > // Use the default constructor. > std::unique_ptr <http://en.cppreference.com/w/cpp/memory/unique_ptr><Vec3> v1 = std::make_unique<Vec3>(); > // Use the constructor that matches these arguments > std::unique_ptr <http://en.cppreference.com/w/cpp/memory/unique_ptr><Vec3> v2 = std::make_unique<Vec3>(0,1,2); > // Create a unique_ptr to an array of 5 elements > std::unique_ptr <http://en.cppreference.com/w/cpp/memory/unique_ptr><Vec3[]> v3 = std::make_unique<Vec3[]>(5); > > std::cout <http://en.cppreference.com/w/cpp/io/cout> << "make_unique<Vec3>(): " << *v1 << '\n' > << "make_unique<Vec3>(0,1,2): " << *v2 << '\n' > << "make_unique<Vec3[]>(5): "; > for (int i = 0; i < 5; i++) { > std::cout <http://en.cppreference.com/w/cpp/io/cout> << std::setw <http://en.cppreference.com/w/cpp/io/manip/setw>(i ? 30 : 0) << v3[i] << '\n'; > }} > > > It failed with the following errors: > Error: no member named 'make_unique' in namespace 'std' > std::unique_ptr<Vec3> v1 = std::make_unique<Vec3>(); > ... ... > > Any idea and suggestion about what is going on? or have I missed > something? The command I used to compile the code above: > $ clang++ a.cpp >Maybe `clang++ -std=c++11 a.cpp` ?> > 2. Comparing this llvm with my current gcc/8.2.0 on a project (openmp > code running 1 thread), it showed that llvm is almost twice as slow as gcc > (both compile with -O3) on my IBM power8 machine. Is it suppose to be with > such slower performance than gcc? >It is very sensitive to how you built it, by default it'll be built in debug mode. For best performance you would ideally you enable Release mode, and bootstrap with LTO/PGO. -- Mehdi> > Thank you very much for any advice! > > Best Regards, > Shelton > > > > > > > > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210211/bca0d680/attachment.html>