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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Michel Morin from comment #3)
> From the safety point of view, I agree with you. But, at the same time, I
> thought that detectable UB (with the help of sanitizers) is useful than
> silent bug. 

Detectable UB doesn't guarantee detection. Sanitizers are not suitable for
production code. Introducing UB here would be strictly less safe, full stop.

And the bug isn't silent, it makes the stream unusable.

> How about `throw`ing as in std::string's constructor?

Set the exception flag on the stream and you get an exception when badbit is
set.

Reply via email to