[Bug tree-optimization/108449] [13 Regression] ICE in eliminate_unnecessary_stmts, at tree-ssa-dce.cc:1512

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 19 07:43:10 GMT 2023


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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so early we still have vfork() 'static' and maybe_special_function_p
returns false.  But then check_global_declaration () comes along and does

  /* Warn about any function declared static but not defined.  We don't
     warn about variables, because many programs have static variables
     that exist only to get some text into the object file.  */
  if (TREE_CODE (decl) == FUNCTION_DECL
      && DECL_INITIAL (decl) == 0
      && DECL_EXTERNAL (decl)
      && ! DECL_ARTIFICIAL (decl)
      && ! TREE_PUBLIC (decl))
    {
      if (warning_suppressed_p (decl, OPT_Wunused))
        ;
      else if (snode->referred_to_p (/*include_self=*/false))
        pedwarn (input_location, 0, "%q+F used but never defined", decl);
      else
        warning (OPT_Wunused_function, "%q+F declared %<static%> but never "
                                       "defined", decl);
      /* This symbol is effectively an "extern" declaration now.  */
      TREE_PUBLIC (decl) = 1;

which will result in maybe_special_function_p to return true.

I suppose leaving the decl static might have an effect on the linker errors
emitted for targets that require special asm ops for undefined external
references, but then you should still get an error here.

This mangling dates back to RMS at r0-3845-g7d429c41c5953f


More information about the Gcc-bugs mailing list