[Bug c/93631] internal compiler error: in gimple_ca ll_arg, at gimple.h:3258

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 17 12:34:00 GMT 2020


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code
             Status|ASSIGNED                    |NEW
                 CC|                            |jsm28 at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
          Component|middle-end                  |c
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
smaller "invalid" testcase (why don't we diagnose it?):

int f2 ( int x [ strcmp ( ) ] , int b ) { return x[0] - b ; } 

it's interesting that if I declare strcmp to avoid an implicit declaration
warning with the following it stops to ICE...

int strcmp();

so somehow the FEs decl merging for an implicit declaration coming from
the argument list is "broken" and doesn't avoid pre-empting the built-in
declaration?

While I have a patch to paper over the issue in the middle-end it would
be nice to avoid the issue in the frontend.  The middle-end patch would do
the following, using the canonical built-in declaration for argument
verification.  Similar issues exist for target builtins since we also
have a target specific folder.  Not sure how the FE deals with user-provided
"bogus" implementations of those (and whether they ever exist in non
__builtin_ obfuscated variants).

diff --git a/gcc/gimple.c b/gcc/gimple.c
index 324e706d508..d64c2a77ea3 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2698,6 +2698,11 @@ gimple_builtin_call_types_compatible_p (const gimple
*stmt, tree fndecl)
 {
   gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);

+  /* Use the decl we are actually expecting for comparison, not a possibly
+     bogus one from the user the C frontend is happily marking as builtin.  */
+  if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+    fndecl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl));
+
   tree ret = gimple_call_lhs (stmt);
   if (ret
       && !useless_type_conversion_p (TREE_TYPE (ret),


CCing C FE folks.


More information about the Gcc-bugs mailing list