My Oracle Support Banner

Using static_cast To Convert Member Functions Not Allowed (Doc ID 2750325.1)

Last updated on MAY 05, 2021

Applies to:

Oracle Solaris Studio - Version 12.4 to 12.6 [Release 12]
Information in this document applies to any platform.

Symptoms

Given the following code

class B {
 public:
   virtual void f( ) = 0;
   virtual void f(int) = 0;
};

class D : public B {
 public:
   virtual void f( ) { }
   virtual void f(int) { }
};

int main()
{
   typedef void (B::*PB)( );
   PB pb = static_cast<PB>(&D::f);
   D d;
   (d.*pb)( );
}

which regularly compiles on Solaris Studio 12.3 with the following command line

# CC -c -o /dev/null <SOURCE_FILE>

when compiling on Oracle Solaris Studio 12.4 and Oracle Developer Studio 12.5/6, the compilation ends with an error

ERROR
-----------
<SOURCE_FILE>, line 16: Error: Using static_cast to convert from void(D::*)() to void(B::*)() not allowed.
1 Error(s) detected.

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.