== Why is this an issue?

``++typedef++``s are a convenient way of encapsulating complex types in simpler names. However, ``++typedef++``ing a pointer type is problematic because when ``++const++`` is applied to the defined type, it makes the pointer constant, not the pointed-to value. Even when that is what's intended, maintainers may misunderstand.


=== Noncompliant code example

[source,cpp]
----
struct book {
  int isbn;
  int publishYear;
};
typedef book;
typedef *pBook;  // Noncompliant

void mangleBook(const pBook pb) {
  pb->isbn = 4;  // this is legal; its the pointer, not the book that's const
  pb->publishYear=1900;
}
----


=== Exceptions

Function pointers are ignored by this rule.


== Resources

* https://www.securecoding.cert.org/confluence/x/14At[CERT, DCL05-C.] - Use typedefs of non-pointer types only


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

=== on 22 Jun 2015, 11:30:55 Ann Campbell wrote:
Why assign this to me?

=== on 22 Jun 2015, 15:21:01 Evgeny Mandrikov wrote:
\[~ann.campbell.2] because counterpart CPP-927 was assigned to you.

=== on 23 Jun 2015, 11:47:20 Ann Campbell wrote:
\[~evgeny.mandrikov] I've added an exception text. I don't see the need to add a code sample to the exception.

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