c++ - ARM cross-compiling, segmentation fault on multiple inheritance -


i have c++ application using multiple inheritance , polymorphism. works correctly on x86_64-linux on arm-linux i'm experiencing segmentation fault.

i've written simple test re-create problem:

#include <list> #include <iostream>  class smartobject {     public:      // removing destructor makes work in way     virtual ~smartobject(){     }      void method(void) {} };  class imyinterface {     public:      // removing destructor have no effect (fails)     virtual ~imyinterface(){     }      virtual std::list<int> getlist() = 0; };  class myobject :  public smartobject, public virtual imyinterface {     public:      myobject()     {         list.push_back(4);         list.push_back(5);     }      virtual std::list<int> getlist() {         return list;     }      std::list<int> list; };  int main() {     imyinterface * ip = new myobject();     std::list<int> list_clone = ip->getlist();     std::cout << list_clone.size() << std::endl;     delete ip;     return 0; } 

this code works correctly on x64-linux , win32 (also on other embedded platforms) on arm-linux causes segmentation fault when calling list_clone.size() because copied list have incorrect tail pointer.

i have tried gcc 4.8.3 , 4.9.1 i've seen same behavior. target architecture arm cortex-a processors hard floating point.

any idea?

actually have find 2 independent ways make work:

  1. by removing smartobject destructor, not feasible on overall application.
  2. by declaring myobject in way (virtual on smartobject , order inverted):

class myobject : public virtual imyinterface, public virtual smartobject

thanks in advance

it's bug of gcc 4.9.x on arm targets. see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66666-


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -