public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61374] New: string_view::operator string() is buggy
@ 2014-05-31  2:21 john.salmon at deshaw dot com
  2014-05-31 10:54 ` [Bug libstdc++/61374] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: john.salmon at deshaw dot com @ 2014-05-31  2:21 UTC (permalink / raw)
  To: gcc-bugs

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$


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-08-04 18:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-31  2:21 [Bug libstdc++/61374] New: string_view::operator string() is buggy john.salmon at deshaw dot com
2014-05-31 10:54 ` [Bug libstdc++/61374] " redi at gcc dot gnu.org
2014-05-31 10:59 ` redi at gcc dot gnu.org
2014-06-01 17:24 ` redi at gcc dot gnu.org
2014-06-01 17:25 ` redi at gcc dot gnu.org
2014-07-16 13:29 ` jakub at gcc dot gnu.org
2014-08-04 18:50 ` redi at gcc dot gnu.org
2014-08-04 18:52 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).