This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix up tree-ssa-strlen.c ICEs (PR tree-optimization/89703)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: Richard Biener <rguenther at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Mar 2019 09:43:22 +0100
- Subject: Re: [PATCH] Fix up tree-ssa-strlen.c ICEs (PR tree-optimization/89703)
- References: <20190313224312.GP7611@tucnak> <alpine.DEB.2.21.1903140046200.10481@digraph.polyomino.org.uk>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Mar 14, 2019 at 12:50:28AM +0000, Joseph Myers wrote:
> > The C FE sadly passes through some really bad prototypes of builtin
> > functions as "harmless":
> > /* Accept "harmless" mismatches in function types such
> > as missing qualifiers or pointer vs same size integer
> > mismatches. This is for the ffs and fprintf builtins.
> > However, with -Wextra in effect, diagnose return and
> > argument types that are incompatible according to
> > language rules. */
>
> Note that this isn't just about pre-standard headers with unexpected types
> (if it were, it might be obsolete). It's also needed for building glibc
> (to build glibc with -Wextra with GCC trunk, one of the -Wno- options
> needed is -Wno-builtin-declaration-mismatch), because of how various code
> creates function aliases between functions that have the same ABI but
> different types (long versus int, etc.).
I was mainly woried about the pointer vs same sized integer mismatches.
Seems we refuse them on arguments:
/* Fail for types with incompatible modes/sizes. */
if (TYPE_MODE (TREE_VALUE (oldargs))
!= TYPE_MODE (TREE_VALUE (newargs)))
return NULL_TREE;
/* Fail for function and object pointer mismatches. */
if ((FUNCTION_POINTER_TYPE_P (oldtype)
!= FUNCTION_POINTER_TYPE_P (newtype))
|| POINTER_TYPE_P (oldtype) != POINTER_TYPE_P (newtype))
return NULL_TREE;
but not on the return type, where there is just:
if (TYPE_MODE (oldrettype) != TYPE_MODE (newrettype))
return NULL_TREE;
Whether a builtin returns a pointer or integer is at least for the
middle-end quite important difference, so I'm just surprised more bugs in
other passes haven't been filed yet. I can deal with that in the
tree-ssa-strlen.c pass with the patch I've posted, just am worried about
potential issues elsewhere.
Jakub