https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71463
Bug ID: 71463 Summary: "ignoring attributes on template argument" in -O1 and above Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mail at milianw dot de Target Milestone: --- I've seen this error with gcc (GCC) 6.1.1 20160501 and code like this: ~~~~~~~~~~~~~~ #include <cstdlib> template<typename T> struct foo {}; foo<decltype(&::malloc)> emit_unexpected_warning; int main() { return 0; } ~~~~~~~~~~~~~~ compiling it without optimizations shows no warning, but from -O1 and onwards I get the unexpected warning on ignored template argument attributes: ~~~~~~~~~~~~~~~ $ g++ -std=c++11 -Wall -Wpedantic -O0 test.cpp # no warnings $ g++ -std=c++11 -Wall -Wpedantic -O1 test.cpp test.cpp:9:24: warning: ignoring attributes on template argument ‘void* (*)(size_t) throw () {aka void* (*)(long unsigned int) throw ()}’ [-Wignored-attributes] foo<decltype(&::malloc)> emit_unexpected_warning; ~~~~~~~~~~~~~~~ Clang does not emit any such warning. I believe it's a false-positive, especially considering that it only shows up in -O1 and higher, but not -O0.