This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/61374] New: string_view::operator string() is buggy


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61374

            Bug ID: 61374
           Summary: string_view::operator string() is buggy
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: john.salmon at deshaw dot com

The problem is the string(length, c) constructor on line 255 of string_view. 
The begin/end constructor is what's needed.  Here's a quick demonstration.

drdlogin0039$ cat bug.cpp
#include <experimental/string_view>
#include <string>

std::experimental::string_view sv("hello world");
std::string s {sv};
drdlogin0039$
drdlogin0039$
drdlogin0039$ dw -m gcc/4.9.0-28B/bin g++ -std=c++1y bug.cpp 
In file included from bug.cpp:1:0:
/aprj/desrad-c/root/Linux/x86_64/gcc/4.9.0-28B/include/c++/4.9.0/experimental/string_view:
In instantiation of 'std::experimental::basic_string_view<_CharT,
_Traits>::operator std::basic_string<_CharT, _Traits, _Allocator>() const [with
_Allocator = std::allocator<char>; _CharT = char; _Traits =
std::char_traits<char>]':
bug.cpp:5:18:   required from here
/aprj/desrad-c/root/Linux/x86_64/gcc/4.9.0-28B/include/c++/4.9.0/experimental/string_view:255:33:
error: invalid conversion from 'const char*' to 'char' [-fpermissive]
      (this->_M_len, this->_M_str);
                                 ^
In file included from
/aprj/desrad-c/root/Linux/x86_64/gcc/4.9.0-28B/include/c++/4.9.0/string:52:0,
                 from
/aprj/desrad-c/root/Linux/x86_64/gcc/4.9.0-28B/include/c++/4.9.0/experimental/string_view:43,
                 from bug.cpp:1:
/aprj/desrad-c/root/Linux/x86_64/gcc/4.9.0-28B/include/c++/4.9.0/bits/basic_string.h:502:7:
note: initializing argument 2 of 'std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>::size_type,
_CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits,
_Alloc>::size_type = long unsigned int]'
       basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
       ^
drdlogin0039$


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]