[Bug c++/98368] Seg fault on template method missing required return statement
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Dec 18 09:16:21 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98368
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
That's expected behavior as your code triggers an undefined behavior:
$ g++ pr98368.C -std=c++17 -fsanitize=undefined,address && ./a.out
pr98368.C: 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]’:
pr98368.C:25:16: required from here
pr98368.C:20:1: warning: no return statement in function returning non-void
[-Wreturn-type]
20 | }
| ^
pr98368.C:16:53: runtime error: execution reached the end of a value-returning
function without returning a value
#0 0x401334 in long SomeTemplate<int, int>::Foo<int>(int const&) const
(/home/marxin/Programming/testcases/a.out+0x401334)
#1 0x40127e in main (/home/marxin/Programming/testcases/a.out+0x40127e)
#2 0x7ffff676e151 in __libc_start_main (/lib64/libc.so.6+0x28151)
#3 0x4010ed in _start (/home/marxin/Programming/testcases/a.out+0x4010ed)
More information about the Gcc-bugs
mailing list