[RFC PATCH] avoid applying attributes to explicit specializations (PR 83871)

Martin Sebor msebor@gmail.com
Tue Feb 6 02:48:00 GMT 2018


On 02/05/2018 05:55 PM, Joseph Myers wrote:
> On Mon, 5 Feb 2018, Martin Sebor wrote:
>
>> On 02/05/2018 04:44 PM, Joseph Myers wrote:
>>> On Sun, 4 Feb 2018, Martin Sebor wrote:
>>>
>>>> We've talked about (2) in the past (bug 71463) but this seems
>>>> like an opportunity to revisit it and (hopefully) make a change
>>>> to treat these the same as all other function attributes rather
>>>> than type attributes.  Besides fixing the wrong code bugs and
>>>
>>> I'd say that actually more attributes should be made into type attributes
>>> where they are currently function attributes - anything that affects
>>> optimizations or warnings in the caller based on properties of the callee
>>> is something where it's meaningful to have a pointer-to-function where the
>>> pointed-to function type has that property.
>>
>> What then happens when the pointer to which the attributes are
>> transferred (presumably by initialization) is then assigned
>> the address of a function that has different attributes that?
>
> The pointer object gets the attributes by being declared with the
> appropriate attribute.  (Example: the error member of struct cpp_callbacks
> in cpplib.h.)  If a pointer to a function that lacks the required property
> is stored in the object with pointer-to-attributed-function type, that's a
> bug - just as it's a bug if a function is declared with an attribute
> without satisfying the required properties.

Oh, I see what you mean.  I thought you were suggesting to
transparently transfer the attributes to the pointer type
on initialization.

I agree that making it possible to explictly specify some
of these attributes on function pointers (i.e., making
them type attributes) would be useful.  Provided, of
course, that incompatible conversions were diagnosed.

Martin



More information about the Gcc-patches mailing list