[Bug ipa/92799] [8/9/10 Regression] ICE on a weakref function definition followed by a declaration

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 14 21:38:00 GMT 2020


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code
             Status|NEW                         |ASSIGNED
                 CC|                            |msebor at gcc dot gnu.org
      Known to work|                            |4.4.3
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
            Summary|ICE: in get, at             |[8/9/10 Regression] ICE on
                   |cgraph.h:1339               |a weakref function
                   |                            |definition followed by a
                   |                            |declaration
      Known to fail|                            |10.0, 4.5.3, 4.6.4, 4.7.4,
                   |                            |4.8.4, 4.9.4, 5.5.0, 6.4.0,
                   |                            |7.2.0, 8.0, 9.2.0

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
According to my bisection this is an ancient regression introduced in GCC 4.5:

First failed revision: 154121
commit a82892595bc3b2a84b13455711a609138dbcb052
Author: Jan Hubicka <jh@suse.cz>
Date:   Thu Nov 12 17:21:59 2009 +0100

    cgraph.h (varpool_node_name): Declare.

            * cgraph.h (varpool_node_name): Declare.
            * cgraphunit.c (process_function_and_variable_attributes): Set
force_output
            flag on used variables.
            * ipa.c (function_and_variable_visibility): Dump externally visible
and needed
            variables.
            * varpool.c (varpool_node_name): Export.
            (decide_is_variable_needed): Check COMDAT for externally visible
vars;
            ignore needed flag.

    From-SVN: r154121

Before then, GCC accepted the code but also dropped the attribute without a
warning.  So I don't think the code is valid -- weakref declarations cannot be
definitions, and under other circumstances GCC diagnoses it when they are by
issuing:

  warning: ‘weakref’ attribute ignored because function is defined
[-Wattributes]

GCC should issue the same diagnostic for the test case in comment #0 and either
drop the attribute as it does in other cases, or it should be changed to reject
definitions with the weakref attribute.  I'm testing a patch that does that.


More information about the Gcc-bugs mailing list