From patchwork Wed Feb 28 14:36:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 879162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-474018-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="lzHzUDCV"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zryn02rVCz9s2B for ; Thu, 1 Mar 2018 01:36:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=m01M+PLUxD9ubQWNY959QB00Walr24s89lPzgwpPOqPGm3QsFB LICsjMTgWXdkvCWpUfxkJMYFlRFWzjgk2nWlC47oQQnp5n8Madmmkh5W/AJTDGiM W0BR6jYroksnO1Pdq1fps6u5/RVApgy9TMZ5SsB1QjLn+LOFocuRhl+M4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=ieb5s7OCTSRBEhNKRJbEbMkewBQ=; b=lzHzUDCVihVd8rgxHXMY yA5cN19O2k/AMOF+/GTPjUUHItLQkmmx+ija7Ljah7yuRaCG4OjRc9g5Fb6HLZgg m23tA54peqIlY4ge2kiQsfAFaoAuqGl6MozRSRE/Zi0//h0+Wt7j3HwcgRIxJXzj Kek7ielXxBepjPNJekuz3hA= Received: (qmail 118253 invoked by alias); 28 Feb 2018 14:36:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 118196 invoked by uid 89); 28 Feb 2018 14:36:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Simply X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Feb 2018 14:36:26 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1SEVhPq139944; Wed, 28 Feb 2018 14:36:23 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2gdw0d8ffw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Feb 2018 14:36:23 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1SEaLiX026839 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Feb 2018 14:36:22 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w1SEaLpN020486; Wed, 28 Feb 2018 14:36:21 GMT Received: from [192.168.1.4] (/87.18.224.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Feb 2018 06:36:20 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch/RFC] PR 71569 ("[6/7/8 regression] Crash: External definition of template member from template struct") Message-ID: Date: Wed, 28 Feb 2018 15:36:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8817 signatures=668681 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802280177 X-IsSubscribed: yes Hi, in this P2 ICE on invalid we fail to diagnose an ill-formed variable template partial specialization and the assert at the beginning of determine_specialization triggers. Indeed, we didn't diagnose the problem via check_specialization_scope (there are no template <>, thus begin_specialization isn't involved). Simply adding a specific check to check_explicit_specialization exactly when we recognize a variable template partial specialization seems a safe thing to do and passes testing. Not sure if the test itself is as simple as possible or is better done somewhere else... Thanks, Paolo. ////////////////////// Index: cp/pt.c =================================================================== --- cp/pt.c (revision 258059) +++ cp/pt.c (working copy) @@ -2873,7 +2873,12 @@ check_explicit_specialization (tree declarator, /* Partial specialization of variable template. */ SET_DECL_TEMPLATE_SPECIALIZATION (decl); specialization = 1; - goto ok; + if (template_count && DECL_CLASS_SCOPE_P (decl) + && template_class_depth (DECL_CONTEXT (decl)) > 0) + error ("variable template partial specialization %qD does " + "not specialize any template arguments", declarator); + else + goto ok; } else if (cxx_dialect < cxx14) error ("non-type partial specialization %qD " Index: testsuite/g++.dg/cpp1y/var-templ58.C =================================================================== --- testsuite/g++.dg/cpp1y/var-templ58.C (nonexistent) +++ testsuite/g++.dg/cpp1y/var-templ58.C (working copy) @@ -0,0 +1,13 @@ +// PR c++/71569 +// { dg-do compile { target c++14 } } + +template +class Foo +{ + template + static bool Bar; +}; + +template +template +bool Foo::Bar; // { dg-error "variable template partial" }