I had an old app that I need to maintain. Thousands of lines of code.
When I switched to the gcc 7.3 compiler and I enabled -flto application started to crash o exit:
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x1ee0c6b0 in ?? () from /lib/libc.so.6
#2 0x1ee0c840 in exit () from /lib/libc.so.6
#3 0x1edf0d5c in ?? () from /lib/libc.so.6
#4 0x1edf0f10 in __libc_start_main () from /lib/libc.so.6
#5 0x00000000 in ?? ()
When I removed -flto option app stopped crashing.
I've traced that unused static variable in a body of one of functions caused the problem:
static std::vector<C_Param*> vpParam;
When I removed 'static' or removed variable at all app stopped crashing.
This is very strange to me because the variable is not used and only happens with the -flto option.
What could be the main cause?