From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31327 invoked by alias); 8 Aug 2016 19:09:20 -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 30540 invoked by uid 89); 8 Aug 2016 19:09:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1,30 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 08 Aug 2016 19:09:17 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8751D4E339 for ; Mon, 8 Aug 2016 19:09:16 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-43.brq.redhat.com [10.40.204.43]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u78J9EcU032412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 8 Aug 2016 15:09:16 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u78J9DVT009169; Mon, 8 Aug 2016 21:09:13 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u78J9CVZ009168; Mon, 8 Aug 2016 21:09:12 +0200 Date: Mon, 08 Aug 2016 19:09:00 -0000 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix ICE when throwing va_list (PR c++/72809) Message-ID: <20160808190912.GO14857@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-08/txt/msg00627.txt.bz2 Hi! If va_list is one-entry array of structs, those RECORD_TYPEs don't have TYPE_BINFO. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? I've made the testcase compile instead of run, because while it with the patch works both on x86_64-linux and i686-linux, not sure if it really should be well defined - at least in C one can copy va_list only through va_copy, by throwing it and catching it is copied in some other way. 2016-08-08 Jakub Jelinek PR c++/72809 * rtti.c (get_pseudo_ti_index): Return TK_CLASS_TYPE for builtin aggregate types without TYPE_BINFO. * g++.dg/eh/stdarg1.C: New test. --- gcc/cp/rtti.c.jj 2016-04-22 18:21:27.000000000 +0200 +++ gcc/cp/rtti.c 2016-08-08 16:21:32.937053462 +0200 @@ -1293,7 +1293,8 @@ get_pseudo_ti_index (tree type) ix = TK_CLASS_TYPE; break; } - else if (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type))) + else if (!TYPE_BINFO (type) + || !BINFO_N_BASE_BINFOS (TYPE_BINFO (type))) { ix = TK_CLASS_TYPE; break; --- gcc/testsuite/g++.dg/eh/stdarg1.C.jj 2016-08-08 16:31:52.553510463 +0200 +++ gcc/testsuite/g++.dg/eh/stdarg1.C 2016-08-08 16:30:20.000000000 +0200 @@ -0,0 +1,30 @@ +// PR c++/72809 +// { dg-do compile } + +#include + +int +foo (int a, ...) +{ + va_list ap; + int r = 0; + va_start (ap, a); + try + { + if (a == 1) + throw (ap); + } + catch (va_list b) + { + r = va_arg (b, int); + } + va_end (ap); + return r; +} + +int +main () +{ + if (foo (0) != 0 || foo (1, 7) != 7) + __builtin_abort (); +} Jakub