This is the mail archive of the gcc-bugs@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]

[Bug c/81824] Warn for missing attributes with function aliases


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81824

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
Okay, that would make sense.  But then what do you mean by "weak, alias,
visibility attributes are expected to differ between different names and
shouldn't be diagnosed."

The example in comment #0 shows a potential bug: declaring an alias to be more
restrictive ("nothrow") than its target makes it possible for the target to
quietly violate the guarantee provided by the alias to its callers.  So I would
expect it to be diagnosed for the reasons of correctness.  (I realize that for
nothrow this isn't applicable to Glibc because nothing in Glibc throws.  But it
is applicable to C++ code bases.)

It's not a potential bug for an alias were less restrictive ("might throw")
than its targets.  It just means that uses of the alias may lead to suboptimal
code compared to the target, and so warning for the mismatch will help point
that out.  

So the warning would be helpful in both cases, just for different reasons.  (In
my view, this is analogous to the const/pure situation we discussed.)

I think the same argument applies to weak.

I haven't thought about visibility too much but it seems different.  I can't
think of a problem with defining an alias with a different visibility than its
target.

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