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.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to