This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/86130] Expect SIGSEGV but program just silently exits


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

--- Comment #10 from Martin Sebor <msebor at gcc dot gnu.org> ---
As a data point, calling printf ("%s", p) does lead to a segfault in Glibc for
a null p because GCC turns the call into puts(p) which doesn't have the same
feature (see https://sourceware.org/bugzilla/show_bug.cgi?id=5618 for the
background).

I think most users prefer invalid uses of pointers to fail loudly so they can
be caught early.  Few users expect output functions to fail, and even fewer
bother to check for failures when writing to standard streams.

Besides the inserter without the test resulting in more efficient code and GCC
emitting a warning when a null pointer is passed to it (it doesn't now even
though it should because of the strlen call), leaving it to the compiler to
deal with can also lead to better code downstream thanks to
-fdelete-null-pointer-checks.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]