[Bug c++/71463] [6/7 regression] unexpected warning: ignoring function return attributes on template argument

jason at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jul 21 05:06:00 GMT 2016


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

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Milian Wolff from comment #8)
> As an interested bystander, may I ask: If the attribute is part of the type,
> shouldn't it then be transferred via decltype() and then also used in the
> template to trigger the warning there?

The attribute isn't properly part of the C++ type, so in the testcase below
A<fna> needs to be the same type as A<fn>, and so they share a member function.
 So we have to choose which type to use as the canonical type, and we choose
the type without the attribute.  And that's what the "ignoring attributes"
warning is telling you.

typedef int fn();
typedef int fna() __attribute ((warn_unused_result));

template <class T>
struct A {
  T *p;
  void g() { p(); }             // no warning                                   
};

int main()
{
  A<fn>().g();
  A<fna>().g();
}


More information about the Gcc-bugs mailing list