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

            Bug ID: 83025
           Summary: xfstream::open with char* gets caught on C++17 path
                    overload.
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 3dw4rd at verizon dot net
  Target Milestone: ---

Created attachment 42627
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42627&action=edit
Example showing error.  Compile with -std=c++17

char* filename = "test.txt"

std::ofstream unit;
unit.open(filename);

when compiled with C++17 gives:

/home/ed/bin/include/c++/8.0.0/fstream: In instantiation of ‘decltype
((void)(((std::basic_ofstream<_CharT,
_Traits>*)this)->std::basic_ofstream<_CharT, _Traits>::_M_filebuf.open(__s,
__mode))) std::basic_ofstream<_CharT, _Traits>::open(const _Path&,
std::ios_base::openmode) [with _Path = char*; _CharT = char; _Traits =
std::char_traits<char>; decltype ((void)(((std::basic_ofstream<_CharT,
_Traits>*)this)->std::basic_ofstream<_CharT, _Traits>::_M_filebuf.open(__s,
__mode))) = void; std::ios_base::openmode = std::_Ios_Openmode]’:
err.cpp:18:27:   required from here
/home/ed/bin/include/c++/8.0.0/fstream:895:13: error: request for member
‘c_str’ in ‘__s’, which is of non-class type ‘char* const’
  { open(__s.c_str(), __mode); }

Reply via email to