https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83749
Bug ID: 83749 Summary: Types with different language linkage are treated as equivalent types Product: gcc Version: 7.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dan.cer...@cgc-instruments.com Target Milestone: --- g++ has an inaccuracy when following the C++03 standard concerning the equality of types with different linkage. Section 7.5.1 states that: "Two function types with different language linkages are distinct types even if they are otherwise identical.". Then the following code snippet should not compile: ~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} extern "C" void (*const interruptVectors[])(); typedef void (*ISR_t)(void); static ISR_t* source_vector_table = const_cast<ISR_t*>(interruptVectors); ~~~~~~~~~~~~~~~~~~~~~~~~ Although interruptVectors is of type const ISR_t* it has C linkage, thus the types should be different and the const_cast should not work. I have discovered this behavior when compiling a code base with TI's ARM compiler which choked on the aforementioned snippet. A TI employee then referred me to the C++03 standard (https://e2e.ti.com/support/development_tools/compiler/f/343/t/654558), which seems to back the compiler's behavior.