Skip to content

CWG3229 [basic.def.odr] Mixing built in operators with overloaded operators or mixing different built in operators for the same token sequence in inline functions #994

Description

@Halalaluyafail3

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

Reference (section label): [basic.def.odr]

Issue description:

Consider the following two translation units:

//TU 1
struct S{};
inline S foo(){
    return S(),S();
}

//TU 2
#include<iostream>
struct S{};
S operator,(S,S){
    std::cout<<"called\n";
    return{};
}
inline S foo(){
    return S(),S();
}

This should probably be IFNDR, but there does not actually appear to be anything that makes it ill-formed. "In each such definition, the overloaded operators referred to, the implicit calls to conversion functions, constructors, operator new functions and operator delete functions, shall refer to the same function." [basic.def.odr]/16.10 is the closest thing, but it appears that it assumes two functions are used. Unary operator& is another scenario where a built in operator can be mixed with an overloaded operator. Additionally, consider the following two translation units:

//TU 1
struct B;
struct C;
inline B*bar(C*p){
    return(B*)p;
}

//TU 2
struct A{int x;};
struct B{int y;};
struct C:A,B{};
inline B*bar(C*p){
    return(B*)p;
}

This should probably be IFNDR as well, but there does not appear to be anything that makes it ill-formed. See also: #990

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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