[Bug c++/86129] New: Expect SIGBUS but program just silently exits
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 13 15:58:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86129
Bug ID: 86129
Summary: Expect SIGBUS but program just silently exits
Product: gcc
Version: 8.1.0
Status: RESOLVED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: p.sanders at alpinesoft dot co.uk
Target Milestone: ---
Status: RESOLVED
Resolution: INVALID
Hi guys,
My first post here, hope I do things right.
The following code snippet just exits the program silently rather than
generating SIGBUS as you would expect it to. I don't think what doing that is
appropriate.
clang *does* generate SIGBUS, and although the code below is, strictly
speaking, UB, I don't think gcc should behave as it does, for obvious reasons.
OK, here's the code:
#include <iostream>
int main()
{
char *p = (char *) nullptr;
std::cout << "Watch the " << p << "birdie" << std::endl;
return 0;
}
And here's the output (note: no SIGBUS):
Watch the
Live demo here (where you can also try running it with clang)
https://wandbox.org/permlink/M1S74HqjT1HvLtr0
Sounds like an easy fix. Thanks.
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Probably some nonnull attribute somewhere. Anyway, GIGO.
More information about the Gcc-bugs
mailing list