From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26732 invoked by alias); 19 May 2011 17:19:28 -0000 Received: (qmail 26722 invoked by uid 22791); 19 May 2011 17:19:26 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 May 2011 17:19:09 +0000 From: "schaub.johannes at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49051] [C++0x] Doesn't SFINAE away an invalid substitution into toplevel parameter type "T[N]" X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: schaub.johannes at googlemail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 19 May 2011 17:21:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg01635.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49051 --- Comment #3 from Johannes Schaub 2011-05-19 16:56:07 UTC --- (In reply to comment #2) > (In reply to comment #1) > > I disagree. The transformation of array to pointer is done immediately at > > declaration time (8.3.5/6), so there is no substitution into an array type. In > > resolving issue 1001, core agreed that the transformations in 8.3.5/6 are done > > at template definition time, not deferred until the instantiation. > > > > http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_closed.html#1001 > > http://wiki.dinkumware.com/twiki/bin/view/Wg21batavia/CoreWorkingGroup#Core_issue_1001_Parameter_type_a > > jason, the transformation is immediately done at declaration time. I agree: > That's why these two are equivalent: > > template void f(T[1]); > template void f(T*); > > For equivalence, both shall have identical parameter-type-lists, which these > have. But before argument deduction, explicit template arguments are > substituted, and those explicit arguments are substituted into the *unadjusted* > parameter type. See 14.8.2p3 (FDIS): > > "After this substitution is performed, the function parameter type adjustments > described in 8.3.5 are performed." > > The note that contains a list of substitution failures also has an example like > that at 14.8.2p8: > > template int f(T[5]); > int I = f(0); > int j = f(0); // invalid array Ah I see now: The substitution for explicit arguments uses the *function type*, not the parameter types (according to p6). So in the example above, it uses "T*" and becomes "void*". It doesn't use "T[5]". p3 only applies when the dependent type was adjusted and substitution made it a non-adjusted type. So on a second read of this, I agree to you. The note at 14.8.2p8 and the example of p3 were confusing me, both tricking me into thinking that for substitution, the parameter types themselves somehow would be used.