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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-01-26
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to fail|                            |7.2.0, 8.0

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
I think it's just a matter of G++ warning that a type attribute is being
dropped when instantiating a template on the type.  This is not entirely
intuitive and there have been other bug reports in the past as a result. 
Here's a small test case:

$ cat t.C && gcc -S -Wall t.C
typedef unsigned cl_uint __attribute__((aligned(4)));

template <class T>
struct vector { };

vector<cl_uint> v;
t.C:6:15: warning: ignoring attributes on template argument ‘cl_uint’ {aka
‘unsigned int’} [-Wignored-attributes]
 vector<cl_uint> v;
               ^

I'll go ahead and confirm this report because the attribute here is superfluous
when an int is 4-byte aligned and so GCC might as well just silently drop it
when it's explicitly specified and avoid issuing a pointless warning.

I also confirm it because I'm bothered by the warning being issued
inconsistently.  For example, in the test case below, instantiating the class
template A on I4 triggers the (pointless in this case) -Wignored-attributes
warning but instantiating the function template g on f does not even though the
-Wreturn-type warning implies that the noreturn attribute was dropped.  I think
GCC should be consistent, if not in applying/dropping attributes then in
issuing the -Wignored-attributes warning.

$ cat t.C && gcc -S -Wall t.C
typedef int I4 __attribute__ ((aligned (4)));

template <class T>
struct A { };
template struct A<I4>;

int __attribute__ ((noreturn)) f ();

template <class T>
int g (T t) { t (); }

void h ()
{
  g (f);
}
t.C:5:21: warning: ignoring attributes on template argument ‘I4’ {aka ‘int’}
[-Wignored-attributes]
 template struct A<I4>;
                     ^
t.C: In function ‘int g(T)’:
t.C:10:21: warning: no return statement in function returning non-void
[-Wreturn-type]
 int g (T t) { t (); }
                     ^

Reply via email to