This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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?

Based on testing, transferring type attributes doesn't seem to
have a beneficial effect on the generated code.  For example,
G++ treats const and pure as function attributes but
returns_nonnull as a type attribute.  Calls made from function
templates via a pointer are treated according to the constness
and "pureness" of the actual argument to the template (i.e.,
that of the function passed to it as an argument).  But similar
calls seem to disregard the returns_nonnull attribute and lead
to suboptimal code when a function with the attribute is passed
to the template.  I haven't spent enough time to understand why
that is yet, but anecdotally what I have seen suggests using
type attributes leads to problems.  At least in C++.

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]