[Bug c++/83749] New: Types with different language linkage are treated as equivalent types

2018-01-09 Thread dan.cer...@cgc-instruments.com
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(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.

[Bug c++/83749] Types with different language linkage are treated as equivalent types

2018-01-09 Thread dan.cer...@cgc-instruments.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83749

--- Comment #2 from dan.cer...@cgc-instruments.com ---
Well I don't mind the current behavior at all and to be honest I find it more
logical that way, so I would welcome a change in the standard.

Should I then close this bugreport or keep it open for further reference?