From patchwork Wed Oct 18 11:07:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 827530 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-464420-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kpoCJCO1"; 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 3yH8RL5wk0z9t4b for ; Wed, 18 Oct 2017 22:07:42 +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=GBbgx+cVIkcRwas3EZmt8C3N6TPkp+jttZ7e8a8j4EvssU5OJW wMQDzzU3lLAqUGDJFuWeOXFjADIksGjcBAQwKXCWIyrdweRXkxXdc9mnDYf3M2T1 HYIn56qe1J/4AStV8UGcN29LtImxaNG4bPwwTEoiwn0vJCqDmkESi046M= 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=hog9XOAKa5vuR5I5aF2PrveRQeA=; b=kpoCJCO17f+h+v3P5ofQ OSCqISdZ56H3XP5ldK75GpV3TP13UdZjbYoK4QFGlb6mINKWiwO72oRUAM7Vdf52 QhbBzfXtvzxu3xdzJUOLt/ds+QHbwQxDVhi5WErXPpraEJ5xtI9FNqHYmZITdYmm 550KFBV729CARoSw6H3kn0Q= Received: (qmail 17486 invoked by alias); 18 Oct 2017 11:07:33 -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 17051 invoked by uid 89); 18 Oct 2017 11:07:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=our X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 11:07:32 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9IB7TJK029238 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Oct 2017 11:07:29 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9IB7SDY014553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Oct 2017 11:07:28 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v9IB7SO7001622; Wed, 18 Oct 2017 11:07:28 GMT Received: from [192.168.1.4] (/79.12.223.140) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 18 Oct 2017 04:07:27 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] PR 80991 ("ICE with __is_trivially_constructible in template") Message-ID: <3fbd71ab-22c8-d0d7-ffd1-83c8ee2b6ea1@oracle.com> Date: Wed, 18 Oct 2017 13:07:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, a rather straightforward issue that we didn't notice so far only because in all our uses of __is_trivially_constructible either neither type is dependent or both are (eg, in library uses). The below handles in the obvious way a possible TREE_LIST - built node by node by cp_parser_trait_expr in the variadic case - as TRAIT_EXPR_TYPE2. Tested x86_64-linux. Seems suitable for the branches too. Thanks, Paolo. /////////////////////// /cp 2017-10-18 Paolo Carlini PR c++/80991 * pt.c (value_dependent_expression_p, [TRAIT_EXPR]): Handle a TREE_LIST as TRAIT_EXPR_TYPE2. /testsuite 2017-10-18 Paolo Carlini PR c++/80991 * g++.dg/ext/is_trivially_constructible5.C: New. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 253842) +++ cp/pt.c (working copy) @@ -24019,8 +24019,21 @@ value_dependent_expression_p (tree expression) case TRAIT_EXPR: { tree type2 = TRAIT_EXPR_TYPE2 (expression); - return (dependent_type_p (TRAIT_EXPR_TYPE1 (expression)) - || (type2 ? dependent_type_p (type2) : false)); + + if (dependent_type_p (TRAIT_EXPR_TYPE1 (expression))) + return true; + + if (!type2) + return false; + + if (TREE_CODE (type2) != TREE_LIST) + return dependent_type_p (type2); + + for (; type2; type2 = TREE_CHAIN (type2)) + if (dependent_type_p (TREE_VALUE (type2))) + return true; + + return false; } case MODOP_EXPR: Index: testsuite/g++.dg/ext/is_trivially_constructible5.C =================================================================== --- testsuite/g++.dg/ext/is_trivially_constructible5.C (nonexistent) +++ testsuite/g++.dg/ext/is_trivially_constructible5.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/80991 +// { dg-do compile { target c++11 } } + +template void foo() +{ + static_assert(__is_trivially_constructible(int, int), ""); +} + +void bar() +{ + foo(); +}