Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Netanel_K_Intel
Employee
66 Views

Pure virtual call behaviour difference between VS and ICC

Hi,

The following code works if compiled with VS but fails with ICC:

class A {
public:
	  virtual void F() = 0;
};

class B : public A {
public:
	  virtual void F() = 0;
};

class C : public B  {
public:
	  virtual void B::F() override {}
};

int _tmain(int argc, _TCHAR* argv[])
{
	  C c;
	  A* a = &c; 
	  a->F();
	  return 0;
}

Obviously, removing the 2nd F declaration in B or the "B::" part from F’s definition in C will remove the issue.

What I was wondering is whether this is a bug or just a quirk and of which of the compilers?

 

0 Kudos
1 Reply
Netanel_K_Intel
Employee
66 Views

Just found that g++ won't compile:

error: cannot define member function ‘B::F’ within ‘C’ virtual void B::F() override {}A

And Intel compiler will indeed issue a warning, but not in the default warning level:

warning #1125: function "A::F()" is hidden by "C::F" -- virtual function override intended?

virtual void B::F() override {}

Visual studio compiles clean.

 

thanks,

Reply