From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67423 invoked by alias); 14 Sep 2015 12:07:40 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 67352 invoked by uid 48); 14 Sep 2015 12:07:36 -0000 From: "forest_software at mail dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/67566] std::move is in global scope g++ 5.1 -std=c++14 Date: Mon, 14 Sep 2015 12:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: forest_software at mail dot ru X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: Message-ID: In-Reply-To: References: 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 X-SW-Source: 2015-09/txt/msg01155.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D67566 --- Comment #2 from Roman Koptev --- I've installed gcc 5.1 from repository http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu on Ubuntu Studio: lsb_release -a LSB Version:=20=20=20 core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd6= 4:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-no= arch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:= security-4.1-amd64:security-4.1-noarch Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty g++ --version g++ (Ubuntu 5.1.0-0ubuntu11~14.04.1) 5.1.0 Copyright (C) 2015 Free Software Foundation, Inc. =D0=AD=D1=82=D0=BE =D1=81=D0=B2=D0=BE=D0=B1=D0=BE=D0=B4=D0=BD=D0=BE =D1=80= =D0=B0=D1=81=D0=BF=D1=80=D0=BE=D1=81=D1=82=D1=80=D0=B0=D0=BD=D1=8F=D0=B5=D0= =BC=D0=BE=D0=B5 =D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D0=BD=D0= =BE=D0=B5 =D0=BE=D0=B1=D0=B5=D1=81=D0=BF=D0=B5=D1=87=D0=B5=D0=BD=D0=B8=D0= =B5. =D0=A3=D1=81=D0=BB=D0=BE=D0=B2=D0=B8=D1=8F =D0=BA=D0=BE=D0=BF=D0=B8=D1= =80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F =D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D1=8B =D0=B2 =D0=B8=D1=81= =D1=85=D0=BE=D0=B4=D0=BD=D1=8B=D1=85 =D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0= =D1=85. =D0=91=D0=B5=D0=B7 =D0=B3=D0=B0=D1=80=D0=B0=D0=BD=D1=82=D0=B8=D0=B8= =D0=BA=D0=B0=D0=BA=D0=B8=D1=85-=D0=BB=D0=B8=D0=B1=D0=BE =D0=BA=D0=B0=D1=87= =D0=B5=D1=81=D1=82=D0=B2, =D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=D1=8F=20 =D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D1=80=D1=87=D0=B5=D1=81=D0=BA=D1=83=D1=8E = =D1=86=D0=B5=D0=BD=D0=BD=D0=BE=D1=81=D1=82=D1=8C =D0=B8 =D0=BF=D1=80=D0=B8= =D0=BC=D0=B5=D0=BD=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D1=8C =D0=B4=D0=BB=D1=8F = =D0=BA=D0=B0=D0=BA=D0=B8=D1=85-=D0=BB=D0=B8=D0=B1=D0=BE =D1=86=D0=B5=D0=BB= =D0=B5=D0=B9. For the program above (main.cpp): #include #include using boost::move; main() { std::string a =3D "fff"; std::string b =3D move(a); } Compile as: g++ main.cpp -std=3Dc++14 I have the output (ambiguous call of overloaded function, Sorry for russian localization): main.cpp: =D0=92 =D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8 =C2=ABint main(= )=C2=BB: main.cpp:9:25: =D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0: =D0=B2=D1=8B=D0=B7=D0= =BE=D0=B2 =D0=BF=D0=B5=D1=80=D0=B5=D0=B3=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0= =BD=D0=BE=D0=B9 =D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8 =C2=ABmove(std::= string&)=C2=BB =D0=BD=D0=B5=D0=BE=D0=B4=D0=BD=D0=BE=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD std::string b =3D move(a); ^ In file included from /usr/include/boost/move/utility.hpp:28:0, from /usr/include/boost/move/move.hpp:29, from main.cpp:2: /usr/include/boost/move/utility_core.hpp:211:77: =D0=B7=D0=B0=D0=BC=D0=B5= =D1=87=D0=B0=D0=BD=D0=B8=D0=B5: candidate: typename boost::move_detail::remove_reference::type&& boost::move(T&&) [with T =3D std::basic_string&; typename boost::move_detail::remove_reference::type =3D std::basic_string] inline typename ::boost::move_detail::remove_reference::type && move(T&& t) BOOST_NOEXCEPT = ^ In file included from /usr/include/c++/5/bits/stl_pair.h:59:0, from /usr/include/c++/5/bits/stl_algobase.h:64, from /usr/include/c++/5/bits/char_traits.h:39, from /usr/include/c++/5/string:40, from main.cpp:1: /usr/include/c++/5/bits/move.h:101:5: =D0=B7=D0=B0=D0=BC=D0=B5=D1=87=D0=B0= =D0=BD=D0=B8=D0=B5: candidate: constexpr typename std::remove_reference< >::type&& std::move(_Tp&&) [with _Tp =3D std::basic_string&; typename std::remove_reference< >::type =3D std::basic_string] move(_Tp&& __t) noexcept ^ Now for simple program (main.cpp): #include main() { std::string a =3D "fff"; std::string b =3D move(a); } Compile with: g++ main.cpp I have the correct error message (no declaration move in this scope): main.cpp: =D0=92 =D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8 =C2=ABint main(= )=C2=BB: main.cpp:6:25: =D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0: =D0=BD=D0=B5=D1=82 =D0= =B4=D0=B5=D0=BA=D0=BB=D0=B0=D1=80=D0=B0=D1=86=D0=B8=D0=B8 =C2=ABmove=C2=BB = =D0=B2 =D1=8D=D1=82=D0=BE=D0=B9 =D0=BE=D0=B1=D0=BB=D0=B0=D1=81=D1=82=D0=B8 = =D0=B2=D0=B8=D0=B4=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B8 std::string b =3D move(a); ^ But if I compile as: g++ main.cpp -std=3Dc++14 It compile successfully and has no any output on stdout or stderr That'is if I compile any program with the option -std=3Dc++14, after includ= ing (may be and other headers) std::move surely and always is in global namespace, available without std:: or using std or using std::move and this= is surely abnormal. >>From gcc-bugs-return-497178-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Sep 14 12:11:51 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 74964 invoked by alias); 14 Sep 2015 12:11:51 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 74906 invoked by uid 48); 14 Sep 2015 12:11:47 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/67566] std::move is in global scope g++ 5.1 -std=c++14 Date: Mon, 14 Sep 2015 12:11:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg01156.txt.bz2 Content-length: 801 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67566 --- Comment #3 from Jonathan Wakely --- (In reply to Roman Koptev from comment #2) > That'is if I compile any program with the option -std=c++14, after including > (may be and other headers) std::move surely and always is in global > namespace, available without std:: or using std or using std::move and this > is surely abnormal. No it isn't in the global namespace, it's in namespace std as required by the C++ standard. What's happening is called Argument Dependent Lookup and is perfectly normal. http://en.cppreference.com/w/cpp/language/adl https://en.wikipedia.org/wiki/Argument-dependent_name_lookup http://stackoverflow.com/questions/8111677/what-is-argument-dependent-lookup-aka-adl-or-koenig-lookup