[Bug libstdc++/88812] New: Implement C++20 LWG 2499/P0487R1 - Fixing operator>>(basic_istream&, CharT*)

emsr at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 11 22:33:00 GMT 2019


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

            Bug ID: 88812
           Summary: Implement C++20 LWG 2499/P0487R1 - Fixing
                    operator>>(basic_istream&, CharT*)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: emsr at gcc dot gnu.org
  Target Milestone: ---

http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0487r1.html

TL;DR Just like deletion of gets() the operator>>(char* str) need to be
replaced by ones that take sized buffers:

#if __cplusplus > 201703L
  // Not in LWG2499/P0487R1
  template<std::size_t _Num>
    basic_istream<char>&
    operator>>(basic_istream<char>& __in, char (&__s)[_Num]);

  template<typename _Traits, std::size_t _Num>
    inline basic_istream<char, _Traits>&
    operator>>(basic_istream<char, _Traits>& __in, unsigned char (&__s)[_Num])
    { return (__in >> reinterpret_cast<char*>(__s)); }

  template<typename _Traits, std::size_t _Num>
    inline basic_istream<char, _Traits>&
    operator>>(basic_istream<char, _Traits>& __in, signed char (&__s)[_Num])
    { return (__in >> reinterpret_cast<char*>(__s)); }
#endif

No, I don't have a complete patch.

We'll need to figure out migration deprecation strategies, ABI compatibility
(keep old sigs in istream.cc, just don't declare publicly?).


More information about the Gcc-bugs mailing list