From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83369 invoked by alias); 15 Feb 2018 23:36:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 83357 invoked by uid 89); 15 Feb 2018 23:36:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f52.google.com Received: from mail-oi0-f52.google.com (HELO mail-oi0-f52.google.com) (209.85.218.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Feb 2018 23:36:55 +0000 Received: by mail-oi0-f52.google.com with SMTP id l124so1142034oib.0 for ; Thu, 15 Feb 2018 15:36:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=u2yta0yXHPvFnyprYsjJZdx1TOVvOCZ1Vh+W2Wfe7XQ=; b=IEB9cHtRgCktZ0BK6L0wPtF9l/CsucJZ+iaIqGpSMu310jrgJrycHmvmWLTJqbL58Q 0XRMk9cuc48eEJ3r2H33Mm+VMOUZwI9CIdEQlp6FxzepLiXbigg9g0D/h18DwV4/ZQg7 hWgnl30c/Fa9PTySwBxYX3PjNWlwHc6N2QpYrEtgsQmzZcKI+DPvvAzG3z/EEasWe0FD f9xUTia12M5ZV8rZL9bSNH7tAFSCvuQIXm+fMpXafJit47HKVb2eARW110faniK4yMbw kBlv/ccc+Wi3IsFzKhGCX350UFLg2YUz0ZmMmN4bd86D0eGfc/rXCies0ZM4qBL/KkrA Hidw== X-Gm-Message-State: APf1xPArdTB6LYknWCHGiIkWRzy3czqgTZVAQt6w4tv6t0MMs553sXm2 9Im5PKkb8BrVY9Z3aXM7mPApvA== X-Google-Smtp-Source: AH8x225WTrOL957WCMoSnjotg9SYuNtmiW0CPw083IfKD7nqiUy7Eob1SVi0VHX/XHN3OO4abdqWYA== X-Received: by 10.202.5.66 with SMTP id 63mr2864679oif.266.1518737812951; Thu, 15 Feb 2018 15:36:52 -0800 (PST) Received: from localhost.localdomain (75-171-228-29.hlrn.qwest.net. [75.171.228.29]) by smtp.gmail.com with ESMTPSA id c20sm7874937oic.40.2018.02.15.15.36.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2018 15:36:51 -0800 (PST) To: Jason Merrill , Gcc Patch List From: Martin Sebor Subject: [PATCH] replace ICE with error for failed template deduction (PR 84355) Message-ID: <786533c4-2017-86c0-8813-0bea046fc7d0@gmail.com> Date: Thu, 15 Feb 2018 23:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4052FDEB3417B65B9BD91E54" X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00944.txt.bz2 This is a multi-part message in MIME format. --------------4052FDEB3417B65B9BD91E54 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 326 A failed template deduction in template member of a template triggers an ICE with -std=c++17 due to what seems like a missing handling of invalid input. Replacing the gcc_unreachable() call that causes the ICE with a return statement indicating the deduction failure eliminates the ICE and restores sane diagnostics. Martin --------------4052FDEB3417B65B9BD91E54 Content-Type: text/x-patch; name="gcc-84355.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-84355.diff" Content-length: 1388 PR c++/84355 - [7/8 Regression] ICE with failing template argument deduction gcc/cp/ChangeLog: PR c++/84355 * pt.c (unify): Return failure instead of asserting. gcc/testsuite/ChangeLog: PR c++/84355 * g++.dg/cpp1z/class-deduction48.C: New test. Index: gcc/cp/pt.c =================================================================== --- gcc/cp/pt.c (revision 257713) +++ gcc/cp/pt.c (working copy) @@ -20918,7 +20918,7 @@ unify (tree tparms, tree targs, tree parm, tree ar && TREE_CODE (tparm) != TYPE_DECL) || (TREE_CODE (parm) == TEMPLATE_TEMPLATE_PARM && TREE_CODE (tparm) != TEMPLATE_DECL)) - gcc_unreachable (); + return unify_invalid (explain_p); if (TREE_CODE (parm) == BOUND_TEMPLATE_TEMPLATE_PARM) { Index: gcc/testsuite/g++.dg/cpp1z/class-deduction48.C =================================================================== --- gcc/testsuite/g++.dg/cpp1z/class-deduction48.C (nonexistent) +++ gcc/testsuite/g++.dg/cpp1z/class-deduction48.C (working copy) @@ -0,0 +1,20 @@ +// PR c++/84355 - ICE with failing template argument deduction +// { dg-do compile } +// { dg-options "-std=c++17" } + +template +struct A +{ + template + struct B + { + B (T); + }; + + A () { + B b (0); // { dg-error "deduction failed" } + // { dg-error "no matching function" "" { target *-*-* } .-1 } + } +}; + +A a; --------------4052FDEB3417B65B9BD91E54--