[cfe-commits] r149685 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
Douglas Gregor
dgregor at apple.com
Fri Feb 3 09:20:54 PST 2012
On Feb 3, 2012, at 12:47 AM, Richard Smith wrote:
> On Thu, Feb 2, 2012 at 11:34 PM, Douglas Gregor <dgregor at apple.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120203/df321ccc/attachment.html>
More information about the cfe-commits
mailing list