Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Alex_K_6
Beginner
486 Views

Pure virtual function has no overrider

I'm getting errors trying to build SpiderMonkey (the Firefox JavaScript engine, which is a module of the source code). I get the following error with this header file:


From what I understand this is part of the C++ standard, but MSVC ignores it, which is why the code compiles. Using the test code in this documentation, ICC 13 SP1 Update 1 also ignores this standard and compiles successfully. Preprocessing the .cpp file where this error occurs doesn't help, as the error is within the header file and is used by more than one .cpp file.

What I'm trying to understand:

  • Is this something due to code Mozilla has changed?
  • Is this error related to just my test environment or can others also recreate this error?

My environment:

  • Windows 7 x64
  • Visual Studio 2012, Update 3
  • ICC 13 SP1 Update 1
  • Firefox 25b12

I've heard of others not having this error, if so what could be in my environment that causes this error to occur?

0 Kudos
4 Replies
QIAOMIN_Q_
New Contributor I
486 Views

what's your gcc's version? have you tried to pass the compilation with the latest gcc?

 

Sukruth_H_Intel
Employee
486 Views

Hi,

    Could you please provide me the url as to download the Spider monkey version of source code that you have downloaded and also the steps to reproduce the same.

Regards,

Sukruth H V

Sukruth_H_Intel
Employee
486 Views

Hi,

     The reason why we generally get this error is basically when we don't implement the overrider. Let me clarify this by giving you an simple example :-

shv:~/quad> cat pure_virtual.cpp
class A
{
public:
typedef unsigned int idtype;
virtual void func(idtype id) = 0; //this is pure virtual function  --1
};
class B
{
public:
class C : public A
{
public:
void func(const A::idtype id)
{  }
};
};
int main(const char *pServerName)
{
B::C C1; //this line gives the compilation error.
return 1;
}

Now in the above code, we could see that i have implemented the overrider and hence i wouldn't see any error. Now let's say i will not implement the overrider, then i get the following error :-

shv:~/quad> cat pure_virtual.cpp
class A
{
public:
typedef unsigned int idtype;
virtual void func(idtype id) = 0; //this is pure virtual function  --1
};
class B
{
public:
class C : public A
{
public:
//void func(const A::idtype id)
{  }
};
};
int main(const char *pServerName)
{
B::C C1; //this line gives the compilation error.
return 1;
}

 

Observe the commented "void func(const A::idtype id)", This would produce the following error, which is the same in your case too.

shv:~/quad> icpc pure_virtual.cpp
pure_virtual.cpp(14): error: expected a declaration
  {  }
  ^

pure_virtual.cpp(19): error: object of abstract class type "B::C" is not allowed:
            pure virtual function "A::func" has no overrider
  B::C C1; //this line gives the compilation error.
       ^

compilation aborted for pure_virtual.cpp (code 2)

Any class having pure virtual function will make that class "Abstract" meaning any class derived from this class has to implement the pure virtual function (Override).

Hope you understand the consequence of this error. Being said that i would like to check the source code of spider monkey, So please do let me know the source version which you are using and where di you download it from as i am not aware of the specific version that you have downloaded.

Regards,

Sukruth H V

 

 

Alex_K_6
Beginner
486 Views

QIAOMIN Q. (Intel) wrote:

what's your gcc's version? have you tried to pass the compilation with the latest gcc?

 

Hi,

From what I can tell GCC 4.8.1 compiles this code successfully.

sukruth-v (Intel) wrote:

Hi,

    Could you please provide me the url as to download the Spider monkey version of source code that you have downloaded and also the steps to reproduce the same.

Regards,

Sukruth H V

You can download it here:

http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/25.0b12/source/firefox-25.0b12.source.tar.bz...

SpiderMonkey is located in mozilla-beta/js/src and can be built like this:

https://developer.mozilla.org/en-US/docs/SpiderMonkey/Build_Documentation#Developer_build

Reply