From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E85353858C35; Sun, 3 Dec 2023 20:10:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E85353858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701634225; bh=xnbl3MvYLYddsrzA9JeskFEVDqNn3QFq8hILk+kcsqM=; h=From:To:Subject:Date:From; b=iCxifQpt7v87IA/zXiCVSQ4hznZmSKL5oCNUhZj5PvoXilU3rK0aGoQQvHUz+Iyv3 yxeaAANoRoNfGKji3Nxn9XNxUuhDwPDLKUj+Uk/45SpqmqYqyEQsnE0HX+uGPmkfQf JzbHe/s2anrv7VhaKvF0h6yJ6IcbizHzP+xBGf0A= From: "eng.ahmad.nour at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112838] New: Compiler is unable to show the exact error location when calling copy ctor for a non-copyable object Date: Sun, 03 Dec 2023 20:10:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eng.ahmad.nour at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112838 Bug ID: 112838 Summary: Compiler is unable to show the exact error location when calling copy ctor for a non-copyable object Product: gcc Version: 10.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eng.ahmad.nour at gmail dot com Target Milestone: --- For this minimal example, the compiler never shows that the "real" cause of= the error is line #13 where the copy ctor is being called. 01 #include 02 #include 03=20=20=20=20 04 class NonCopyable 05 { 06 private: 07 std::vector> mElements; 08 }; 09=20=20=20=20 10 int main() 11 { 12 NonCopyable a; 13 NonCopyable b(a); 14=20=20=20=20=20=20 15 return 0; 16 } I'm compiling using:=20 g++-10 -Wall -Wextra main.cpp And getting this: In file included from /usr/include/c++/10/vector:66, from main.cpp:1: /usr/include/c++/10/bits/stl_uninitialized.h: In instantiation of =E2=80=98_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIte= rator, _ForwardIterator) [with _InputIterator =3D __gnu_cxx::__normal_iterator*, std::vector > >; _ForwardIterat= or =3D std::unique_ptr*]=E2=80=99: /usr/include/c++/10/bits/stl_uninitialized.h:325:37: required from =E2=80=98_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _Inpu= tIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator =3D __gnu_cxx::__normal_iterator*, std::vector > >; _ForwardIterator =3D std::unique_ptr<= int>*; _Tp =3D std::unique_ptr]=E2=80=99 /usr/include/c++/10/bits/stl_vector.h:558:31: required from =E2=80=98std:= :vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp =3D std::unique_ptr; _Alloc =3D std::allocator >]=E2= =80=99 main.cpp:4:7: required from here /usr/include/c++/10/bits/stl_uninitialized.h:137:72: error: static assertion failed: result type must be constructible from value type of input range 137 | static_assert(is_constructible<_ValueType2, decltype(*__first)>::value, |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^~~~~ Compiler only shows that error is related to the class NonCopyable. But it = was a nightmare for me to try and find the exact line where copying was made in= the whole project.=