== Why is this an issue?

Empty declarations are cruft; they (may) compile, but they violate the language standards, don't contribute anything of value, and clutter up the program. Like cobwebs, they should be swept away.


=== Noncompliant code example

[source,cpp]
----
int;  // Noncompliant
----


== Resources

* ISO/IEC 9899:2011, 6.7p2 
* ISO/IEC 14882:2011, 7p3.
* https://wiki.sei.cmu.edu/confluence/x/5dUxBQ[CERT, MSC12-C.] - Detect and remove code that has no effect or is never executed


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

'''
== Implementation Specification
(visible only on this page)

=== Message

Remove this empty declaration.


'''
== Comments And Links
(visible only on this page)

=== on 24 Mar 2015, 19:03:23 Evgeny Mandrikov wrote:
\[~ann.campbell.2] we could also add that this actually violates restrictions in standard - see C11 6.7p2 and CPP11 7p3, but might be accepted by compilers.

=== on 24 Mar 2015, 19:32:50 Ann Campbell wrote:
Added [~evgeny.mandrikov]. Is there an officially hosted copy of the language standards we can link to?

=== on 24 Mar 2015, 22:07:05 Evgeny Mandrikov wrote:
\[~ann.campbell.2] ISO standards are paid.

=== on 25 Mar 2015, 13:04:35 Ann Campbell wrote:
One more question [~evgeny.mandrikov] is C11 the full, official name of the standard? Should I throw "ISO" in there?

=== on 25 Mar 2015, 18:08:20 Evgeny Mandrikov wrote:
\[~ann.campbell.2] according to \http://en.wikipedia.org/wiki/C%2B%2B - "{cpp}11" is informal name for "ISO/IEC 14882:2011", "CPP11" - is a name, which we use in code to refer to it. Similarily for "C11" - \http://en.wikipedia.org/wiki/C11_(C_standard_revision).

=== on 25 Mar 2015, 20:03:24 Ann Campbell wrote:
Thanks [~evgeny.mandrikov]

=== on 25 Mar 2015, 20:14:39 Evgeny Mandrikov wrote:
\[~ann.campbell.2] however I'm not sure that usual developers know that "9899" refers to "C" and "14882" to "{cpp}" :) but that's probably not a problem, so overall LGTM.

=== on 23 Nov 2015, 21:40:30 Ann Campbell wrote:
\[~evgeny.mandrikov] I've just mapped this to PC-Lint rule 814


____
useless declaration -- A tagless struct was declared without a declarator.  For example:

----
struct { int n; };
----
Such a declaration cannot very well be used.

____

Is that case already covered, or is a ticket needed?

=== on 24 Nov 2015, 15:03:51 Evgeny Mandrikov wrote:
\[~ann.campbell.2] I suppose that this case was not covered, but you can check by yourself ;)

Also IMO such change requires more investigations, because:

{noformat}

struct {

  int i;

};

{noformat}

gives warning ("declaration does not declare anything") with Clang in C mode and error ("anonymous structs and classes must be class members") in {cpp} mode, while no messages for

{noformat}

struct S {

  struct {

    int i; // can be accessed as "s.i"

  };

} s;

{noformat}

which is probably related to \https://msdn.microsoft.com/en-us/library/a3bbz53t.aspx and \https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html.

And in any case seems that current rule description is not applicable for such case, because it doesn't violate standards.


Also could be noted that seems that PC-Lint rule 814 available only for C.

=== on 24 Nov 2015, 15:17:59 Ann Campbell wrote:
\[~evgeny.mandrikov] you do realize you didn't actually answer the question, right? ;-)


Should I unmap, or do you feel this case is worth covering?


Re only-for-C, I had planned to follow up on that issue separately. In short: yes. I'm lazy.

=== on 5 Feb 2016, 16:46:42 Evgeny Mandrikov wrote:
\[~ann.campbell.2] my answer was - given current description I don't see why PC-Lint 814 maps to this RSPEC.

=== on 5 Feb 2016, 17:02:00 Evgeny Mandrikov wrote:
\[~ann.campbell.2] and to add a little bit more oil into fire of this discussion - some other cases in CPP-1371

=== on 5 Feb 2016, 17:09:30 Ann Campbell wrote:
unmapped

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