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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2019-01-11
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to emsr from comment #0)
> 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)); }

This cast needs to be to char(&)[_Num] or it tries to call the old signature.

> 
>   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)); }

Same here.

> #endif
> 
> No, I don't have a complete patch.

Coincidentally I just implemented this.

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

I think we should keep the old declarations for C++98 - C++17 in the public
headers. We definitely need to keep exporting the definition from the library.

We can add the new declarations for C++2a only (and maybe for -std=gnu++NN
modes too, or expose them via some new macro, to allow users to either opt in
or opt out).

Reply via email to