* [Bug libstdc++/67566] <string> std::move is in global scope g++ 5.1 -std=c++14
[not found] <bug-67566-4@http.gcc.gnu.org/bugzilla/>
2015-09-13 23:35 ` [Bug libstdc++/67566] <string> std::move is in global scope g++ 5.1 -std=c++14 redi at gcc dot gnu.org
@ 2015-09-14 12:07 ` forest_software at mail dot ru
1 sibling, 0 replies; 2+ messages in thread
From: forest_software at mail dot ru @ 2015-09-14 12:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67566
--- Comment #2 from Roman Koptev <forest_software at mail dot ru> ---
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:
core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch: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.
Это свободно распространяемое программное обеспечение. Условия копирования
приведены в исходных текстах. Без гарантии каких-либо качеств, включая
коммерческую ценность и применимость для каких-либо целей.
For the program above (main.cpp):
#include <string>
#include <boost/move/move.hpp>
using boost::move;
main()
{
std::string a = "fff";
std::string b = move(a);
}
Compile as:
g++ main.cpp -std=c++14
I have the output (ambiguous call of overloaded function, Sorry for russian
localization):
main.cpp: В функции «int main()»:
main.cpp:9:25: ошибка: вызов перегруженной функции «move(std::string&)»
неоднозначен
std::string b = 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: замечание: candidate: typename
boost::move_detail::remove_reference<T>::type&& boost::move(T&&) [with T =
std::basic_string<char>&; typename
boost::move_detail::remove_reference<T>::type = std::basic_string<char>]
inline typename ::boost::move_detail::remove_reference<T>::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: замечание: candidate: constexpr typename
std::remove_reference< <template-parameter-1-1> >::type&& std::move(_Tp&&)
[with _Tp = std::basic_string<char>&; typename std::remove_reference<
<template-parameter-1-1> >::type = std::basic_string<char>]
move(_Tp&& __t) noexcept
^
Now for simple program (main.cpp):
#include <string>
main()
{
std::string a = "fff";
std::string b = move(a);
}
Compile with:
g++ main.cpp
I have the correct error message (no declaration move in this scope):
main.cpp: В функции «int main()»:
main.cpp:6:25: ошибка: нет декларации «move» в этой области видимости
std::string b = move(a);
^
But if I compile as:
g++ main.cpp -std=c++14
It compile successfully and has no any output on stdout or stderr
That'is if I compile any program with the option -std=c++14, after including
<string> (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: <gcc-bugs-return-497178-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/67566] <string> 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: <bug-67566-4-tUm8pBKbXc@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67566-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67566-4@http.gcc.gnu.org/bugzilla/>
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?idg566
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Roman Koptev from comment #2)
> That'is if I compile any program with the option -std=c++14, after including
> <string> (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
^ permalink raw reply [flat|nested] 2+ messages in thread