http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57869
Bug ID: 57869
Summary: [C++11] Casting a object pointer to a function pointer
should not warn about a forbidden conversion
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: daniel.kruegler at googlemail dot com
gcc 4.9.0 20130616 (experimental) diagnoses a warning for the following code
compiled with the flags:
-Wall -pedantic -std=c++11
//-------------------------------------
void* po = 0;
void (*pf)() = reinterpret_cast<decltype(pf)>(po); // #2
static_assert(sizeof(po) >= sizeof(pf), "Conversion not supported");
//-------------------------------------
"main.cpp|2|warning: ISO C++ forbids casting between pointer-to-function and
pointer-to-object [enabled by default]"
Given that 5.2.10 p8 says:
"Converting a function pointer to an object pointer type or vice versa is
conditionally-supported."
and since to my knowledge gcc supports such conversions (without that ::dlopen
wouldn't work), the warning should be removed in the context of C++11.