== Why is this an issue?

{cpp}11 introduced "Attributes". They provide a unified syntax to specify additional information about your code.

 They can be applied to various things like types, variables, functions, names, blocks, and translation units.

 {cpp} defines some standard attributes like \[[noreturn]], \[[nodiscard]], \[[deprecated]], \[[fallthrough]]...


Unfortunately, it is possible to use unknown attributes: attributes that are not defined. Your code will compile, but the unknown attribute will be silently ignored. This means that your code will not behave in the way you expected.


=== Noncompliant code example

[source,cpp]
----
void test1(int p) {
  switch (p) {
    case 0:
    case 1:;
      [[std::fallthrough]]; // Noncompliant [[std::fallthrough]] isn't a defined attribute
    default: 
      break;
  }
}
----


=== Compliant solution

[source,cpp]
----
void test1(int p) {
  switch (p) {
    case 0:
    case 1:;
      [[fallthrough]];
    default: 
      break;
  }
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

=== on 7 May 2020, 09:12:42 Geoffray Adde wrote:
Whatre you intending to do for compiler-specific attributes? have a whitelist of namespaces?


for example:

 https://docs.microsoft.com/en-us/cpp/cpp/attributes?view=vs-2019

endif::env-github,rspecator-view[]
