[Bug libstdc++/67566] <string> std::move is in global scope g++ 5.1 -std=c++14

forest_software at mail dot ru gcc-bugzilla@gcc.gnu.org
Mon Sep 14 12:07:00 GMT 2015


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.


More information about the Gcc-bugs mailing list