PR middle-end/46949: ICE on weakrefs

IainS developer@sandoe-acoustics.co.uk
Thu Jan 27 13:16:00 GMT 2011


On 27 Jan 2011, at 11:35, IainS wrote:

>
> On 27 Jan 2011, at 11:25, Richard Guenther wrote:
>
>> 2011/1/27 Jan Hubicka <hubicka@ucw.cz>:
>>>>>  for (vnode = varpool_nodes; vnode != first_var; vnode = vnode- 
>>>>> >next)
>>>>> @@ -887,6 +895,14 @@ process_function_and_variable_attributes
>>>>>         else if (vnode->finalized)
>>>>>           varpool_mark_needed_node (vnode);
>>>>>       }
>>>>> +      if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
>>>>> +         && vnode->finalized)
>>>>
>>>> your testcase has a function and you test vnode?
>>>
>>> Yes, there is typo. I fixed it and also added DECL_INITIAL(decl) ! 
>>> = NULL
>>> to handle darwin that finalize BSS.
>>
>> finalize BSS?!
>
> where do we do this?
>
> If it is in the case of ObjC meta-data - then it is possible that  
> the reason is that the target-specific section choice never gets  
> called because of:
>
> varasm.c (get_variable_section):
>
>  if (ADDR_SPACE_GENERIC_P (as)
>      && !DECL_THREAD_LOCAL_P (decl)
>      && !(prefer_noswitch_p && targetm.have_switchable_bss_sections)
>      && bss_initializer_p (decl))
>    {
>      if (!TREE_PUBLIC (decl))
> 	return lcomm_section;
>      if (bss_noswitch_section)
> 	return bss_noswitch_section;
>    }
>
> which means we end up with meta-data appearing in BSS -- I've got a  
> fix for this as part of a patch-in-progress for ObjC m64
>
>> So we accept
>>
>> static int bss __attribute__((weakref)) = 0;
>>
>> ?  How's that not a definition? ;)
>
>
> if that's not the case in point, then what are we doing wrong? (and  
> I'll try and fix it)

see also an un-reviewed  RFC

http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01469.html


>
> Iain
>
>
>>
>>>>
>>>>> +       {
>>>>> +         warning_at (DECL_SOURCE_LOCATION (node->decl),  
>>>>> OPT_Wattributes,
>>>>> +                     "%<weakref%> attribute ignored"
>>>>> +                     " because variable is initialized");
>>>>> +         DECL_WEAK (decl) = 0;
>>>>
>>>> What if the function has __attribute__((weak,weakref))?  Then the
>>>> above is wrong as we want to retain the weak but not the weakref.
>>>
>>> You can't have this, since weak is allowed only on public, while  
>>> weakref
>>> only on static vars.
>>>
>>> Honza
>>>>
>>>> Richard.
>>>>
>>>>> +       }
>>>>>      process_common_attributes (decl);
>>>>>    }
>>>>> }
>>>>> Index: testsuite/gcc.dg/attr-weakref-4.c
>>>>> = 
>>>>> ==================================================================
>>>>> --- testsuite/gcc.dg/attr-weakref-4.c   (revision 0)
>>>>> +++ testsuite/gcc.dg/attr-weakref-4.c   (revision 0)
>>>>> @@ -0,0 +1,3 @@
>>>>> +/* { dg-do compile } */
>>>>> +/* { dg-require-weak "" } */
>>>>> +static void __attribute__((weakref("bar"))) foo(void) { } /*  
>>>>> { dg-warning "attribute ignored because function is defined" } */
>>>>>
>>>
>



More information about the Gcc-patches mailing list