Open xmh0511 opened 3 years ago
@opensdh, is there a problem here that "corresponds" doesn't actually compare the function return type? Should we augment the comparison accordingly?
It’s deliberate that “corresponds” ignores return types, so that
void f();
int f();
declare one function (invalidly). (This approach works well across translation units since we need some means of recognizing when they might mangle the same way.)
In general, we do rely on [basic.link]/11 to reject “corresponds but…” cases, but that doesn’t apply well here because we describe this in terms of a substitution that might or might not actually be “processed” as a declaration. We should probably check the return types explicitly; it might be good to introduce a term for “corresponds and…”, which would largely reconstitute the prior usage of “would be a well-formed redeclaration of”.
[temp.friend] p5 says
Consider a simplified example from the formal example that follows [temp.friend] p5
A<T>
at#1
can be deduced fromA<int>
at#2
, substitute the deduced template arguments into the friend declaration producevoid A<int>::f();
, whereas the member of the specialization isint A<int>::f();
, according to [basic.scope#scope-3.3.1]In this case, both declarations do not declare function templates, the variance of the return types of such two declarations is not considered when determining whether they correspond or not.
Should we say that?
Since [basic.link] p11 requires that any two declarations of an Entity shall have the same type. In this case, substitute
int
into#1
will cause an invalid declaration.@opensdh @jensmaurer