https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89218
Bug ID: 89218 Summary: [8/9 Regression] g++ miscompiles functions returning non-void without return statements Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ldv at sourceware dot org Target Milestone: --- $ gcc -xc++ -S -O - <<EOF static int foo() {} int main() { return foo(); } EOF <stdin>: In function 'int foo()': <stdin>:1:19: warning: no return statement in function returning non-void [-Wreturn-type] Results to main: .LFB1: .cfi_startproc .cfi_endproc Executing this results to segfault. Miscompilation happens with -Og and higher optimization levels. gcc -xc is fine.