== Why is this an issue?

The ``++delete++`` operator expects a pointer argument. Passing an object to it may compile and seem to run (with an implicit cast to pointer type), but it can result in unexpected behavior at runtime.


=== Noncompliant code example

[source,cpp,diff-id=1,diff-type=noncompliant]
----
class CString {
public:
  operator const char*();
  // ...
};

void fun() {
  CString str;
  // ...
  delete str;  // Noncompliant
}
----


=== Compliant solution

[source,cpp,diff-id=1,diff-type=compliant]
----
class CString {
public:
  operator const char*();
  // ...
};

void fun() {
  CString *pstr = new CString;
  // ...
  delete pstr;
}
----

== Resources

* {cpp} reference - https://en.cppreference.com/w/cpp/memory/new/operator_delete[operator delete]

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

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

=== Message

"xxx" is not a pointer.


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

=== on 8 Apr 2015, 16:53:38 Evgeny Mandrikov wrote:
\[~ann.campbell.2] I feel that word "operator" should be added to title, so what do you think about:

Operand of "delete" operator should have pointer type

Operator "delete" should be used only for pointers



=== on 8 Apr 2015, 18:47:39 Evgeny Mandrikov wrote:
LGTM.

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