This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix ICE with __builtin_va_list on i?86 (PR middle-end/78716)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Tom de Vries <Tom_deVries at mentor dot com>
- Date: Mon, 12 Dec 2016 13:18:59 +0100
- Subject: Re: Fix ICE with __builtin_va_list on i?86 (PR middle-end/78716)
- Authentication-results: sourceware.org; auth=none
- References: <20161208210759.GL2337@redhat.com> <20161212110316.GT3541@tucnak.redhat.com> <20161212120915.GZ2337@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Dec 12, 2016 at 01:09:16PM +0100, Marek Polacek wrote:
> Yeah, given
> expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (expr)), expr);
> in build_va_arg it seems it'll always be a pointer, so the following is
Well, if you think it is guaranteed it always is a pointer, then you could
just gcc_{,checking_}assert it there.
The code will fail an assertion anyway if it is not a pointer type, because
then have_va_type will be still NULL and thus
gcc_assert (have_va_type != NULL_TREE);
will ICE, so I bet it really doesn't matter if you write it as:
if (have_va_type == NULL_TREE)
{
gcc_assert (POINTER_TYPE_P (TREE_TYPE (valist)));
have_va_type
= targetm.canonical_va_list_type (TREE_TYPE (TREE_TYPE (valist)));
}
gcc_assert (have_va_type != NULL_TREE);
or as you wrote it.
So your patch LGTM.
> Bootstrap/regtest running on x86_64-linux, ok for trunk if it passes?
>
> 2016-12-12 Marek Polacek <polacek@redhat.com>
>
> PR middle-end/78716
> * gimplify.c (gimplify_va_arg_expr): Don't require ADDR_EXPR for
> Case 1; check POINTER_TYPE_P instead.
>
> * g++.dg/other/vararg-5.C: New.
Jakub