riccibruno marked an inline comment as done. riccibruno added inline comments.
================ Comment at: test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-associated-namespaces-classes.cpp:304 + static_assert(f(g3) == 4, ""); // FIXME: Also well-formed from the union rule. + // expected-error@-1 {{use of undeclared}} + } ---------------- Quuxplusone wrote: > I see how `g3` matches the example in CWG997 > http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#997 > However, I don't see how CWG997's resolution actually affected this example > in the slightest. The wording inserted for CWG997 was, "Additionally, if the > aforementioned set of overloaded functions is named with a template-id, its > associated classes and namespaces are those of its type template-arguments > and its template template-arguments." That makes e.g. > > f(g3<N::S>) > > consider `N::f`, because `N::S` is a "type template-argument" of the > template-id `g3<N::S>` which names the set of overloaded functions. But it > doesn't do anything at all to `f(g3)` because `g3` is not a template-id and > doesn't have any template-arguments. > > This piece of ADL is implemented only by GCC (not EDG, Clang, or MSVC), and > personally I would very much like to keep it that way. We know there's no > real-world code that expects or relies on CWG997 — because such code would > never work in practice except on GCC. Let's keep it that way! As soon as you > implement a crazy arcane rule, such that code _could_ portably rely on it, > code _will start_ relying on it... and then we'll never be able to simplify > the language. > Case in point: the piece of ADL described in this blog post -- > https://quuxplusone.github.io/blog/2019/04/09/adl-insanity-round-2/ > As soon as the above-described arcane ADL rule was implemented in GCC and > Clang, Boost.Hana started relying on it; and now the rule is "locked in" to > the paper standard because there's real-world code relying on it. > Personally I'd like to _keep_ real-world code from relying on CWG997, until > someone figures out what CWG was thinking when they added it. I think that the relevant part of CWG 997 is the removal of the restriction on non-dependent parameter types. Sure, `g3` is not a `template-id`, but it refers to an overload set which contains the second `g3`, and one of the parameter of this second `g3` is `N::Q<T>`. I don't think this is a surprising rule. It matches the general intuition that for function types ADL is done based on the function parameter types and return type. Not having this rule introduces a difference between function templates and functions in overload sets. Consider https://godbolt.org/z/UXHqm2 : ``` namespace N { struct S1 {}; template <typename> struct S2 {}; void f(void (*g)()); } void g1(); // #1 void g1(N::S1); // #2 void g2(); // #3 template <typename T> void g2(N::S2<T>); // #4 void test() { f(g1); // ok, g1 is #1 f(g2); // should be ok, g2 is #3 } ``` Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60570/new/ https://reviews.llvm.org/D60570 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits