From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59958 invoked by alias); 10 Jul 2015 09:50:38 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 59946 invoked by uid 89); 10 Jul 2015 09:50:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.3 required=5.0 tests=AWL,BAYES_50,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,SPF_SOFTFAIL,URI_HEX autolearn=no version=3.3.2 X-HELO: mbob.nabble.com Received: from mbob.nabble.com (HELO mbob.nabble.com) (162.253.133.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Jul 2015 09:50:35 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id 0198910D5B47 for ; Fri, 10 Jul 2015 02:50:33 -0700 (PDT) Date: Fri, 10 Jul 2015 09:50:00 -0000 From: achkan To: gcc-help@gcc.gnu.org Message-ID: <1436521831306-1167297.post@n5.nabble.com> Subject: segfault when functions are defined in headers or inlined MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2015-07/txt/msg00029.txt.bz2 Hi, 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 //which 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 4.8.4-2ubuntu1~14.04) 4.8.4. Any help will greatly be appreciated. Achkan SALEHI achkan.salehi@cea.fr ashsalehi4133@gmail.com -- 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.