https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114888

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #3)
> Seems we're missing a dependence check in the sizeof / sizeof code:
> 
> diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
> index e5a52dc2b39..284f6e29e36 100644
> --- a/gcc/cp/typeck.cc
> +++ b/gcc/cp/typeck.cc
> @@ -5500,7 +5500,7 @@ cp_build_binary_op (const op_location_t &location,
>             type0 = TREE_TYPE (type0);
>           if (!TYPE_P (type1))
>             type1 = TREE_TYPE (type1);
> -         if (type0
> +         if (type0 && type1
>               && INDIRECT_TYPE_P (type0)
>               && same_type_p (TREE_TYPE (type0), type1))
>             {

Yeah, I was about to suggest that too (just with && on a separate line.
I wonder if TREE_TYPE (type0) could be NULL even when type0 is INDIRECT_TYPE_P,
if yes,
we should be testing also && TREE_TYPE (type0) after the INDIRECT_TYPE_P check.

Reply via email to