https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116954
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2024-10-03 Ever confirmed|0 |1 Known to work| |12.1.0, 12.4.0, 7.1.0, | |9.1.0 Summary|-Wsuggest-attribute=format |[13/14/15 Regression] |false positive for function |format attribute is being |template |lost for function template | |with a depedent type | |argument and decl merging Keywords| |diagnostic Status|UNCONFIRMED |NEW Known to fail|13.2.0, 13.3.0, 13.3.1, |3.4.6 |14.1.0, 14.2.0 | --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Actually the problem is not with `Wsuggest-attribute=format` but rather the C++ front-end losing the format attribute when it comes to dependent array types and merging decls. Take: ``` #ifndef WORKS template<int N> int fn(char (&buf)[N], const char fmt[], ...) __attribute__ ((__format__ (__printf__, 2, 3))); #endif template<int N> __attribute__ ((__format__ (__printf__, 2, 3))) int fn(char (&)[N], const char [], ...) { return 0; } int main() { char buf[20]; return fn(buf, "%s", 42); /* { dg-warning "Wformat" } */ } ``` This used to work in some versions of GCC but no longer works.