Please see attached, which fails to compile. If you compile with -DWORKAROUND you can "prove" to yourself that it ought to compile.
Created attachment 26045 [details] test case compile with -std=c++11 to see the failure. Additionally add -DWORKAROUND to demonstrate why it ought to work.
Could this be related to Bug 45873?
(In reply to comment #2) > Could this be related to Bug 45873? Not if your explanation in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45873#c2 is correct, I think. This is a straightforward pack expansion with no change in the number of arguments.
Reduced: template <class T> T list(T x); template <class H, class ...T> auto list(H h, T ...args) -> decltype(list(args...)); auto list3 = list(1, 2, 3);
The problem here is that the variadic 'list' is not in scope when the trailing-return-type is parsed. 3.3.2 says, The point of declaration for a name is immediately after its complete declarator and the declarator includes the trailing-return-type. And then since all the arguments are integers, no argument-dependent lookup is done, so the call in the trailing-return-type doesn't find the right template, and fails. The versions of EDG and Clang that I have handy seem to reject this testcase on the same basis. This seems like a flaw in the standard.
Jason, are you submitting (or is there already) an issue for this?
This is core issue 1433, classified as an extension in Kona. I don't know if EWG has taken a look at it yet.
*** Bug 59481 has been marked as a duplicate of this bug. ***
Ville, has EWG taken a look at this issue? I'm sorry this didn't come up in the C++14 context, as it would have made sense to fix this when we were adding deduced return types.
(In reply to Jason Merrill from comment #9) > Ville, has EWG taken a look at this issue? I'm sorry this didn't come up in Not yet. The handling of Extension-status Core Issues was more or less on hold while EWG was handling papers targeting C++14. I do intend to tell the EWG chair that we need to speed up the handling of such issues, they are already in the EWG issues list, this particular one is http://cplusplus.github.io/EWG/ewg-index.html#104 Wording and/or implementation experience would certainly be very welcome. ;)
*** Bug 61178 has been marked as a duplicate of this bug. ***
(In reply to Jason Merrill from comment #4) > Reduced: > > template <class T> T list(T x); > > template <class H, class ...T> > auto list(H h, T ...args) -> decltype(list(args...)); > > auto list3 = list(1, 2, 3); Interestingly it works for (static or non-static) member functions: struct X { template <class T> T list(T x); template <class H, class ...T> auto list(H h, T ...args) -> decltype(list(args...)); }; auto list3 = X{}.list(1, 2, 3);
Also I guess we can unsuspend this and close as INVALID now that EWG rejected it. And maybe issue a diagnostic for comment 12, as EDG and clang do?
(In reply to Jonathan Wakely from comment #13) > And maybe issue a diagnostic for comment 12, as EDG and clang do? We started to reject comment #12 in GCC 8+.
(In reply to Andrew Pinski from comment #14) > (In reply to Jonathan Wakely from comment #13) > > And maybe issue a diagnostic for comment 12, as EDG and clang do? > > We started to reject comment #12 in GCC 8+. It's rejected since r8-5270-g2b031ef48e365e25.
Then this seems resolved, until/unless someone actually proposes to make it well-formed.