I have ROOT 6.04/02 installed in my office and 6.11/01 at home. I tried to run something I’ve written in my office at home and "illegal instruction " error appears. It is weird because my code run perfectly fine in my office. After debugging my code, I found out the problem arises because I failed to declare the destructor of an abstract class virtual. The following code illustrates my problem:
#ifndef CLASSTEST_H
#define CLASSTEST_H
#include <iostream>
class test
{
public:
test(){};
/*virtual*/ ~test(){}; // without virtual declaration, it causes problem explained below
virtual void cout() = 0;
};
class test1 : public test
{
public:
test1(){};
~test1(){};
void cout() { std::cout << " this is test1\n";};
};
class test2 : public test
{
public:
test2(){};
~test2(){};
void cout() { std::cout << " this is test2\n";};
};
#endif
Save the code to Classtest.h, load it with “.L Classtest.h” and run the following script "for(int i = 1; i < 2; ++i){ std::unique_ptr<test> a(new test1);}"
. It runs without problems on ROOT 6.04/02 and ROOT 6.10/02, but on ROOT 6.11/01, it gives "illegal instruction ". By uncommenting virtual keyword, the problems is solved. Why is that so? Are there changes in how the interpreter interpret macro?