This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/86368] New: an unknown [[attribute]] should not trigger a warning in C++17


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

            Bug ID: 86368
           Summary: an unknown [[attribute]] should not trigger a warning
                    in C++17
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: h2+bugs at fsfe dot org
  Target Milestone: ---

[this issue is split from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86243 ]

Unknown attributes currently produce warnings in GCC (-Wattributes), however
since C++17 the standard clearly states that C++ attributes (those with
[[name]]) should be ignored when unknown:
 "Any attribute-token that is not recognized by the implementation is ignored." 

The purpose here is to let programmers add attributes that may not be supported
on a platform (yet) and not force them to workaround their non-existance on
that platform (be it via macros or extra compiler arguments). 

I would argue that is a very important aspect of attributes and that it will
become increasingly important when more C++2a attributes are implemented in GCC
and clang ([[likely]] [[unlikely]], [[expects: ]]...). I would even suggest not
including a warning with -Wall or -Wextra, because an unknown attribute is and
in the future even more likely will be part of the design and not an error.
Moreover there is no clean way to workaround the warning, other than using
macros which is not a clean way ;-)
A stand-alone flag would of course still be useful to detect mistyped known
attributes, but this should not trigger by default and IMHO also not with
regular quality control (-Wall -Wextra).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]