segfault when functions are defined in headers or inlined
Fri Jul 10 09:50:00 GMT 2015
Being from the computer vision community, I'm not sure who to turn to when
it comes to compiler problems, so I apologize in advance in case this is not
the most appropriate place to post this question.
The library that I'm trying to compile segfaults whenever an inlined member
function returns. Inspecting the code with gdb shows that the following
happens for all inline member functions (I'm really sorry, the code is
proprietary but I will post code as close as possible to the original one) :
//in the header of an given class
ret & some_class::get_some_member()
return this->_some_member;* //the address of some member is the same it
was when the this instance was created
//where the call is made
var=some_class_instance.get_some_member();//the address of the variable
changes. The function actually returns a new
//instance of _some_member, using its default constructor
later results in segfaults
The only solution that I have found is to remove the function definition
from the headers to the .cpp files. That way, the adress that function
returns is correct, and execution continues until the next inlined function
and the next segfault. Given that the library is quite large, removing
definition from headers is not an option. Furthermore, it seems to me that
g++ ignores the -fno-inline flag even though I have removed every
optimization flag. Is this a known issue?
I'm working on Ubuntu 14.04 64bit, with g++ version g++ (Ubuntu
Any help will greatly be appreciated.
View this message in context: http://gcc.1065356.n5.nabble.com/segfault-when-functions-are-defined-in-headers-or-inlined-tp1167297.html
Sent from the gcc - Help mailing list archive at Nabble.com.
More information about the Gcc-help