[Bug c++/109364] Missing return statement in a non void function gives only a warning but produces a forced crash.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109364 --- Comment #10 from contact at thunderperfectwitchcraft dot org --- Now I get it, thanks to you both. Why not additionally make the -Werror=return-type option to default? Would make it easier to detect and solve the issue, compared to a crashing binary.
[Bug c++/109364] Missing return statement in a non void function gives only a warning but produces a forced crash.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109364 --- Comment #7 from contact at thunderperfectwitchcraft dot org --- I'm not sure if I understand you correct (as I'm not a native speaker): You say that it crashes by chance because it is undefined behavior, right? On reddit, I got this as a reply: "I noticed that GCC13 seems to now add a purposeful invalid instruction to functions that have a return type, like Clang does. So your program crashes instead of attempting to continue with some trash return value." Which wouldn't be by chance to my understanding. What is correct?
[Bug c++/109364] Missing return statement in a non void function gives only a warning but produces a forced crash.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109364 --- Comment #5 from contact at thunderperfectwitchcraft dot org --- As mentioned, it isn't anymore: According to the linked Thread in gcc 13 a return value that contains a invalid instruction is generated on purpose if there is no return statement, forcing a crash. To my understanding, this is the only thing that can happen now.
[Bug c++/109364] Missing return statement in a non void function gives only a warning but produces a forced crash.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109364 --- Comment #3 from contact at thunderperfectwitchcraft dot org --- I'm not sure if you read the thread I linked: If the statements there are correct, atm a instruction that causes a crash under any circumstances is generated and returned if the statement is missing.
[Bug c++/109364] New: Missing return statement in a non void function gives only a warning but produces a forced crash.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109364 Bug ID: 109364 Summary: Missing return statement in a non void function gives only a warning but produces a forced crash. Product: gcc Version: 13.0 URL: https://www.reddit.com/r/gcc/comments/123ojov/no_retur n_in_function_binary_crashes_with/ Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: contact at thunderperfectwitchcraft dot org Target Milestone: --- Calling int Test() { std::cout << "Test"; } from main causes the program to crash, even though only a warning is given. As pointed out in this thread https://www.reddit.com/r/gcc/comments/123ojov/no_return_in_function_binary_crashes_with/ this is because a invalid instruction is returned to cause the crash to prevent people from letting out the return statement. But here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43943 it is stated that it should be only a warning since it can work if the return value isn't used anywhere. This is no longer the case, as there is no way to bring this code to run as far as I can see. To reduce the confusion it should be a error by default, everything else is only frustrating.