dynamic_cast BUG on ICC 7.x for Linux

dynamic_cast BUG on ICC 7.x for Linux

EXAMPLE :

class BaseA
{
public:
virtual void op(){};
};

class BaseB
{
public:
virtual void op(){};
};

class DerivedA : public BaseA
{
public:
virtual void op(){};
};

class DerivedAAB : public DerivedA, public BaseB
{
public:
virtual void op(){};
};

int main(void)
{

DerivedAAB * DAAB = new DerivedAAB;

DerivedA * DA_DAAB = dynamic_cast(DAAB);

BaseB * BB3 = dynamic_cast(DA_DAAB);

if(BB3)
{
// WITH ICC 6.0.1 BB3 NOT NULL OK
printf("OK!
");
}
else
{
// WITH ICC 7.X BB3 NULL ERROR
printf("OOPS!
");
}
}

publicaciones de 6 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

gcc v3.2 also has a problem with dynamic_cast as I have discovered.

Check out bug report 9433 of the latest release of gcc (v3.2.2)

http://gcc.gnu.org/cgi-bin/gnatsweb.pl

It appears that the next release of gcc (v3.2.3) should fix this bug and it is due out on April 15th. If you are experiencing a similar bug using icc I wonder if this is due to both compilers using the same library/header . . .

Are you using RedHat 8.0?

Hope this helped
Sean

I have an example where a dyamic_cast of a reference type seg-fault, but when rewritten as a cast of a pointer type it apparantly works OK. The crash is in

0x400606fe in __dynamic_cast () from /opt/intel/compiler70/ia32/lib/libcxa.so.3

#include

class Base
{
public:
virtual ~Base() {}
};

class Derived : public Base
{
public:
void foo() const { std::cout << "foo() called
"; }
};

Base& obj()
{
static Derived d;
return d;
}

int main()
{
bool ShouldCrash = true; // set to false to get Derived::foo() called with no crash

if (ShouldCrash)
{
dynamic_cast(obj()).foo();
}
else
{
dynamic_cast(&obj())->foo();
}
}

Is anyone from Intel reading this?

Ian - I somehow missed this thread.
Please note that when you find what appears to be an issue in the compiler please dont hesitate to file an issue on the support website premier.intel.com.

Looking at this really briefly, I am not sure I know the cause for the error. Got to debug the runtime.

I am logging this internally and will keep you posted on any updates.

Has any progress been made on uncovering this error?

The original issue posted by jonnyfat seems to be fixed
in the latest Intel compiler.

[jain@jaffa jain]$ icpc test1.cpp
[jain@jaffa jain]$ ./a.out
OK!

[jain@jaffa jain]$ icpc -V
Intel C++ Compiler for 32-bit applications, Version 7.1 Build 20030507Z
...
...

CP

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya