On Wed, 9 Aug 2017, Martin Sebor wrote:

> The problem isn't that the declarations aren't merged at the call
> site but rather that the middle-end gives const precedence over
> pure so when both attributes are provided the former wins.

But that precedence is correct.  Any function with the semantics of const 
also has the semantics of pure.  The problem is that the function doesn't 
have the semantics of the attribute it's declared with.  And any 
diagnostic based purely on the presence of both attributes would be 
essentially a style diagnostic - for the style principle "if you have 
multiple declarations of a function, they should have the same 
information" - rather than "these attributes are inconsistent".

(An optional warning for different information in different declarations 
is reasonable enough.  Actually in glibc it would be useful to have a 
warning for a different but related case - two functions both declared, 
later one defined as an alias of another, but the declarations don't have 
the same attributes.  I'm pretty sure there are cases where the internal 
declaration of __foo is missing attributes present on the public 
declaration of foo.  But such a warning for aliases is only appropriate 
for attributes that are properties of the function, not attributes that 
are properties of particular names for it - __foo may well be a hidden 
symbol where foo isn't.)

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

Reply via email to