Skip to content

Missing mangling specification for parenthesized unresolved names #188

@hubert-reinterpretcast

Description

@hubert-reinterpretcast

Consider the following case:

struct A {
  operator char *();
};

inline namespace N {
  char x(char *);
}
inline namespace M {
  char x(long long *);
}

template <typename T> void f(char (*)[sizeof (x)(T{})]) {}
template <typename T> void f(char (*)[sizeof x(T{})]) {}

short x(const A &);

void g(char (*p)[sizeof(char)]) { f<A>(p); }
void h(char (*p)[sizeof(short)]) { f<A>(p); }

What scope the name x belongs to is necessary unknown in the context of the calls from the template definitions.
As can be seen, both functions are callable with the same template arguments.
I do not see anything in the specification that provides a mangling for the parenthesized name.

Clang appears to handle this by using cp in place of cl for the call expression; however, this solution does not exactly handle the case where a unary & operator either forms a pointer or a pointer-to-member:

struct A { int x; };

char q(int *);
short q(int A::*);

template <typename T>
int f(char (*)[sizeof(q(&T::x))]) { return 1; }

template <typename T>
int f(char (*)[sizeof(q(&(T::x)))]) { return 2; }

int g(char (*p)[sizeof(char)] = 0) { return f<A>(p); }
int h(char (*p)[sizeof(short)] = 0) { return f<A>(p); }

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