From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27574 invoked by alias); 20 Feb 2015 11:24:48 -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 Received: (qmail 27490 invoked by uid 48); 20 Feb 2015 11:24:44 -0000 From: "harald at gigawatt dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64969] generic functions do not work with placeholder return types Date: Fri, 20 Feb 2015 11:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: harald at gigawatt dot nl X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg02247.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64969 Harald van Dijk changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #3 from Harald van Dijk --- This happens because auto is encoded as a template parameter that is one level deeper than the currently deepest real template parameter. In other words, auto f() is encoded as <> f(), and template auto f() is encoded as template <> f(). Given auto f1(auto x), when the first auto is parsed, it becomes <> f1(auto x). When the second auto is parsed, and the function implicitly becomes a template, it looks like template > > <> f1(<> x) where the first <> should be <>. Instead of fixing up existing references to auto when a function is implicitly made a template, how about encoding auto as a template argument with a level of zero, and adding a tf_auto flag for tsubst to specify that auto is to be replaced? If that flag is specified, fix up the zero by changing it to (processing_template_decl+1), if that flag is not specified, leave auto alone. All that seems to be needed aside from that, in a quick test, is making reduce_template_parm_level aware of them, making it leave a level of zero at zero. The cases in this bug pass, and manually running tests on gcc/testsuite/g++.dg/cpp1y/auto* doesn't show problems either. I'll do some more extensive testing, and also run the full test suite.