https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98368
Bug ID: 98368
Summary: Seg fault on template method missing required return
statement
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kip at thevertigo dot com
Target Milestone: ---
Created attachment 49792
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49792&action=edit
Example to generate seg fault.
I am experiencing a core dump when attempting to compile code that is missing a
required return statement in a function that returns a non-void type.
$ g++ --version
g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Minimal attached.
$ g++ test2.cpp -o test2 -O3 -std=c++17 && ./test2
test2.cpp: In instantiation of ‘SomeTemplate<Type1, Type2>::NodeOffsetType
SomeTemplate<Type1, Type2>::Foo(const Type3&) const [with Type3 = int; Type1 =
int; Type2 = int; SomeTemplate<Type1, Type2>::NodeOffsetType = long int]’:
test2.cpp:25:16: required from here
test2.cpp:20:1: warning: no return statement in function returning non-void
[-Wreturn-type]
20 | }
| ^
Segmentation fault (core dumped)