public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/111729] New: Design considerations for operator<<(basic_ostream&, const charT*)
@ 2023-10-08 17:42 llvm at rifkin dot dev
2023-10-08 17:45 ` [Bug libstdc++/111729] " pinskia at gcc dot gnu.org
2023-10-08 18:04 ` llvm at rifkin dot dev
0 siblings, 2 replies; 3+ messages in thread
From: llvm at rifkin dot dev @ 2023-10-08 17:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111729
Bug ID: 111729
Summary: Design considerations for operator<<(basic_ostream&,
const charT*)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: llvm at rifkin dot dev
Target Milestone: ---
The following program violates a precondition specified in the standard and is
UB however it leads to some surprising behavior
#include <iostream>
int main() {
std::cout<<(const char*)nullptr;
std::cout<<"test";
}
There is no segfault, no abort, no non-zero exit status, and no exception.
Instead the program silently continues with the output stream's badbit set.
This can silently ruin the behavior of the rest of the program leaving the
programmer to pull their hair out over what on earth is happening.
Yes, it's UB and the programmer can't expect anything, however it's a very easy
mistake to make and the current behavior makes tracking down that mistake
exceedingly difficult.
I would like to humbly suggest that any of the following behaviors would be
better: Segfaulting, throwing an exception, aborting, an assertion failure in
debug, or printing "(null)" (which is the %s behavior). Libc++ and msvc's stl
both segfault here.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/111729] Design considerations for operator<<(basic_ostream&, const charT*)
2023-10-08 17:42 [Bug libstdc++/111729] New: Design considerations for operator<<(basic_ostream&, const charT*) llvm at rifkin dot dev
@ 2023-10-08 17:45 ` pinskia at gcc dot gnu.org
2023-10-08 18:04 ` llvm at rifkin dot dev
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-08 17:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111729
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 86130.
*** This bug has been marked as a duplicate of bug 86130 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/111729] Design considerations for operator<<(basic_ostream&, const charT*)
2023-10-08 17:42 [Bug libstdc++/111729] New: Design considerations for operator<<(basic_ostream&, const charT*) llvm at rifkin dot dev
2023-10-08 17:45 ` [Bug libstdc++/111729] " pinskia at gcc dot gnu.org
@ 2023-10-08 18:04 ` llvm at rifkin dot dev
1 sibling, 0 replies; 3+ messages in thread
From: llvm at rifkin dot dev @ 2023-10-08 18:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111729
--- Comment #2 from Jeremy R. <llvm at rifkin dot dev> ---
Thank you for the quick response
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-08 18:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-08 17:42 [Bug libstdc++/111729] New: Design considerations for operator<<(basic_ostream&, const charT*) llvm at rifkin dot dev
2023-10-08 17:45 ` [Bug libstdc++/111729] " pinskia at gcc dot gnu.org
2023-10-08 18:04 ` llvm at rifkin dot dev
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).