https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89160
Bug ID: 89160 Summary: -Wattributes too eager on C++11 attributes Product: gcc Version: 8.2.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- A random testcase to illustrate: [[hahaha]] int i; $ g++-snapshot a.c -c -std=gnu++2a a.c:1:16: warning: 'hahaha' attribute directive ignored [-Wattributes] 1 | [[hahaha]] int i; | ^ The standard, in [dcl.attr.grammar], says: "Any attribute-token that is not recognized by the implementation is ignored." I believe the intent is that it should be **silently** ignored, unless I really ask for it clearly with something like -Wunknown-c++-attribute (definitely not part of -Wall). There is a strong requirement that standard attributes have to be safe to ignore. I believe I should be able to use newer (C++20) attributes without having older (C++17) compilers complain so noisily. Sadly, clang is just as bad, and ISTR reading that visual studio was even worse, rejecting programs with C++17 attributes in C++14 mode. As a result, we keep having to write a lot of preprocessor nonsense :-(