https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102378
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2021-09-16
Target Milestone|--- |12.0
Ever confirmed|0 |1
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> (In reply to Andrew Pinski from comment #1)
> > GCC warns only at instantiation time.
>
> And it has been that way since at least 4.4.0.
Not quite. It depends on where a warning is implemented. As the test case
below shows, G++ does diagnose some problems in uninstantiated templates but
not others. Jason's suggestion in the review I pointed to is to try to do
better and the purpose of this bug is to capture that limitation and
improvement for the work I'm doing.
$ cat t.C && gcc -S -Wall -Wredundant-tags t.C
struct A { A (); ~A (); };
template <class T>
void f ()
{
volatile struct A a; // -Wredundant-tags (good)
register int n = sizeof a; // -Wregister (good)
__builtin_memset (&a, 0, n); // missing -Wclass-memaccess and volatile A*
to A* conversion warning
}
t.C: In function ‘void f()’:
t.C:6:12: warning: redundant class-key ‘struct’ in reference to ‘struct A’
[-Wredundant-tags]
6 | volatile struct A a; // -Wredundant-tags (good)
| ^~~~~~
| ------
t.C:7:16: warning: ISO C++17 does not allow ‘register’ storage class specifier
[-Wregister]
7 | register int n = sizeof a; // -Wregister (good)
| ^