Hi,

after tracking down an issue [1] in dvisvgm [2] related to GCC 4.5.0, it
turned out that GCC 4.5.0 doesn't handle sub-classes defined and
instantiated in a template's method properly. At least on x86_64 Linux
systems, the code listed below leads to a segfault, while it works on
Windows/MinGW (x64). I built it with "g++ -g f1.cpp f2.cpp main.cpp".

valgrind backtrace:

==12833== Process terminating with default action of signal 11 (SIGSEGV)
==12833==  Bad permissions for mapped region at address 0x0
==12833==    at 0x0: ???
==12833==    by 0x400C9B: C<double>::doit() (c.h:22)
==12833==    by 0x400B77: f2() (f2.cpp:6)
==12833==    by 0x400D65: main (main.cpp:7)

Does anybody know if this is a known issue, or should I file a bug report?

Regards,
Martin


[1]
http://sourceforge.net/tracker/?func=detail&aid=3031498&group_id=145640&atid=762580

[2] http://dvisvgm.sourceforge.net


-------- main.cpp --------
#include "f1.h"
#include "f2.h"

int main () {
  f1();
  f2();
}

-------- f1.h --------
#ifndef F1_H
#define F1_H

void f1 ();

#endif

-------- f1.cpp --------
#include "f1.h"
#include "c.h"

void f1 () {
  C<int> c;
  c.doit();
}

-------- f2.h --------
#ifndef F2_H
#define F2_H

void f2 ();

#endif

-------- f2.cpp --------
#include "f2.h"
#include "c.h"

void f2 () {
  C<double> c;
  c.doit();
}

-------- c.h --------
#ifndef C_H
#define C_H

#include <iostream>

template <typename T>
class C
{
  public:
    struct Actions {
      virtual ~Actions () {}
      virtual void fail () {}
    };

    void doit () {
      struct DoitActions : Actions {
        void fail () {
          std::cout << "hello\n";
        }
      } actions;
      perform_actions(actions);
    }

    void perform_actions (Actions &actions) {
      actions.fail();
    }
};

#endif

Reply via email to