-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
state: please discussplease discuss the issue or vote for your favorite optionplease discuss the issue or vote for your favorite option
Description
With the new GCC 7.1.1 there is a bug with reassigning to strings.
In this code
#include <string>
#include <iostream>
#include <json.hpp>
using json = nlohmann::json;
int main() {
json js;
std::string name = "";
name = js["name"];
}it produces the error
In file included from /usr/include/c++/7.1.1/string:52:0,
from json_error.cc:1:
/usr/include/c++/7.1.1/bits/basic_string.h: In instantiation of ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_Tp) [with _Tp = nlohmann::basic_json<>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> = std::__cxx11::basic_string<char>&]’:
json_error.cc:10:21: required from here
/usr/include/c++/7.1.1/bits/basic_string.h:764:28: error: call of overloaded ‘assign(nlohmann::basic_json<>&)’ is ambiguous
{ return this->assign(__sv); }
^
/usr/include/c++/7.1.1/bits/basic_string.h:1313:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
assign(const basic_string& __str)
^~~~~~
/usr/include/c++/7.1.1/bits/basic_string.h:1329:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
assign(basic_string&& __str)
^~~~~~
/usr/include/c++/7.1.1/bits/basic_string.h:1440:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__sv_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__sv_type = std::basic_string_view<char>]
assign(__sv_type __sv)
^~~~~~
when built with g++ -std=c++1z filename.cpp but it will compile fine with c++ -std=c++14 filename.cpp
this also occurs if using clang if the GCC libs version is 7.1.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
state: please discussplease discuss the issue or vote for your favorite optionplease discuss the issue or vote for your favorite option