Ambiguities in [dcl.link]

29 views
Skip to first unread message

Viacheslav Usov

unread,
Oct 23, 2015, 6:51:19 AM10/23/15
to ISO C++ Standard - Discussion
I have a few concerns about the current draft's [dcl.link] (which is not really different from that in the current standard). This might have been addressed earlier; if so, kindly point me to the previous discussions.

Paragraph 1 says, in a note, that "Some of the properties associated with an entity with language linkage are specific to each implementation and are not described here." As far as I know, a note in an ISO standard is not normative, so it is not clear what relevance this really has on the rest of the section. "Specific to each implementation" is not a term defined in the standard, so the meaning of that passage is uncertain.

Para 2 specifies that any language linkage except "C" and "C++" are implementation-defined, which hopefully eliminates the ambiguity introduced by the afore-mentioned note for those linkages.

Para 3 stipulates that every implementation shall support "C" and "C++" linkages. It can probably be inferred from para 1 that the "C++" linkage is described by the rest of the C++ standard. But it is unclear who/what specifies the "C" linkage. Paras 4 & 6 specify some aspects of the "C" linkage, but it is unclear whether this is a complete set of requirements and who/what is responsible for all the other aspects.

Para 9 specifies that linkage to C++ objects is implementation-defined. I interpret that as linkage to names with external linkage (because the term "linkage", as defined in [basic.link], applies to names, not to objects). But what about C++ objects exposed via functions or pointer variables with the "C" linkage?

It seems possible to interpret all of the above as that the "C" linkage is not even "implementation-defined".

A particular aspect here is exceptions. Example:

extern "C" typedef void (*F)();

// defined in a C-language translation unit
// or may be not!
extern "C" void g(F f);

extern "C" void h() { return throw 1; }

int main()
{
   g(h);
   return 0;
}

It is reasonably well known [1] that the run-time behaviour of this program is indeed highly "specific to each implementation"; but is that really standard compliant? If yes, according to what?

Cheers,
V.


Reply all
Reply to author
Forward
0 new messages