On Feb 3, 2012, at 12:47 AM, Richard Smith wrote:

> On Thu, Feb 2, 2012 at 11:34 PM, Douglas Gregor <[email protected]> wrote:
> Author: dgregor
> Date: Fri Feb  3 01:34:46 2012
> New Revision: 149685
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=149685&view=rev
> Log:
> Implement support for a pack expansion into a fixed-length
> template. Such pack expansions can easily fail at template
> instantiation time, if the expanded parameter packs are of the wrong
> length. Fixes <rdar://problem/10040867>, PR9021, and the example that
> came up today at Going Native.
>  
> Awesome!
> 
> I note we now accept:
> 
> template<typename,typename,typename> struct S {};
> template<typename T, typename U> using U = S<T, int, U>;
> template<typename...Ts> int f(U<Ts...>, Ts...);
> int k = f({}, 0, 0);
> 
> ... which should probably be considered invalid (see the thread on the core 
> reflector starting with message 20878).

Nice catch. Personally, I think it should be well-formed. I've gone ahead and 
implemented it in r149697; if the discussion next week goes the other way, it's 
simple enough to revert my change and reject this code (but I don't like it in 
the intermediate state where it accepts + mangles poorly).

> [Incidentally, we mangle that as
> 
>   _Z1fIJiiEEi1SIDpT_iT0_ES2_
> 
> which looks like
> 
>   template<typename ...Ts = {int,int}> int f(S<Ts..., int, U>, Ts...);
> 
> (where U is a nonexistent second template parameter). I've not been able to 
> trigger a mangling like that without using one of these non-substitutable 
> alias templates.]


Good point, thanks!

        - Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to