https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65623
Bug ID: 65623 Summary: Incorrect location of error messages on calling copy constructor of unique_ptr Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com When I was compiling a large class file, gcc emit an error that I called the copy constructor of unique_ptr. It took me a while to figure out the cause of the error. I find that clang pinpoints this error. I think this error message can be improved with a precise location of the error. The current location is just the end of the initializer list. $: cat t.cc #include <memory> using namespace std; class A { const int a; const unique_ptr<A> b; const int c; public: A(const A& copy) : a(copy.a), b(copy.b), c(copy.c) { } }; $: g++-4.9 -std=c++11 -c t.cc t.cc: In copy constructor ‘A::A(const A&)’: t.cc:11:13: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = A; _Dp = std::default_delete<A>]’ c(copy.c) { ^ In file included from /usr/local/gcc-4.9.0/include/c++/4.9.0/memory:81:0, from t.cc:1: /usr/local/gcc-4.9.0/include/c++/4.9.0/bits/unique_ptr.h:356:7: note: declared here unique_ptr(const unique_ptr&) = delete; ^ $: clang-trunk -std=c++11 -c t.cc t.cc:10:5: error: call to deleted constructor of 'const unique_ptr<A>' b(copy.b), ^ ~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:273:7: note: 'unique_ptr' has been explicitly marked deleted here unique_ptr(const unique_ptr&) = delete; ^ 1 error generated. $: