Title
Language linkage of member function parameter types and the ODR
Status
c++11
Section
6.3 [basic.def.odr]
Submitter
James Widman

Created on 2008-02-15.00:00:00 last changed 123 months ago

Messages

Date: 2010-08-23.00:00:00

[Voted into WP at August, 2010 meeting.]

Date: 2010-03-15.00:00:00

Proposed resolution (March, 2010):

Add a new bullet following 6.3 [basic.def.odr] paragraph 5, second bullet:

...Given such an entity named D defined in more than one translation unit, then

  • each definition of D shall consist of the same sequence of tokens; and

  • in each definition of D, corresponding names, looked up according to 6.5 [basic.lookup], shall refer to an entity defined within the definition of D, or shall refer to the same entity, after overload resolution (12.2 [over.match]) and after matching of partial template specialization (13.10.4 [temp.over]), except that a name can refer to a const object with internal or no linkage if the object has the same literal type in all definitions of D, and the object is initialized with a constant expression (7.7 [expr.const]), and the value (but not the address) of the object is used, and the object has the same value in all definitions of D; and

  • in each definition of D, corresponding entities shall have the same language linkage; and

  • ...

Date: 2022-09-25.18:08:42

I thought this case would result in undefined behavior according to 6.3 [basic.def.odr]:

    // t.h:
    struct A { void (*p)(); };

    // t1.cpp:
    #include "t.h" // A::p is a pointer to C++ func

    // t2.cpp:
    extern "C" {
    #include "t.h" // A::p is a pointer to C func
    }

...but I don't see how any of the bullets in the list in paragraph 5 apply.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: wp -> fdis
2010-11-29 00:00:00adminsetstatus: dr -> wp
2010-08-23 00:00:00adminsetmessages: + msg2905
2010-08-23 00:00:00adminsetstatus: ready -> dr
2010-03-29 00:00:00adminsetstatus: review -> ready
2010-02-16 00:00:00adminsetmessages: + msg2521
2010-02-16 00:00:00adminsetstatus: drafting -> review
2008-06-29 00:00:00adminsetstatus: open -> drafting
2008-02-15 00:00:00admincreate