Skip to content

What is the behavior if the program invokes an external entity #425

@xmh0511

Description

@xmh0511

Full name of submitter (unless configured in github; will be published with the issue): Jim X

Since [lex.phases] p1.9 says:

All external entity references are resolved. Library components are linked to satisfy external references to entities not defined in the current translation.

and [dcl.link] says we can link to that entity. Consider this case:

extern "C"{
   void fun();
}
int main(){
 fun(); // #1
}
// impl.S
.globl _fun
_fun:
    ret

What's the behavior at #1? Is it implementation-defined or unspecified behavior, or just UB? Because this is a well-formed program, according to [intro.abstract] p5, it must have some observable behaviors. However, the current standard says nothing in this case.

Suggested Resolution

[dcl.link] p10 may be changed to cover this case

Linkage from C++ to objects/functions defined in other languages and to objects/functions defined in C++ from other languages is implementation-defined and language-dependent.

Then, the implementation should be responsible for telling the complete story.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions