C & C++

C & C++

Made by DeepSource

Unintended implicit conversion of a boolean pointer in a condition CXX-W2002

Bug risk
Major
Autofix

A pointer to the boolean type is used in the if condition with implicit conversion. The same pointer is never dereferenced.

A boolean pointer that is never dereferenced and is only directly referenced within a boolean expression indicates a possible missing dereference operation.

Bad practice

void func(const bool *status) {
  /// here status is never dereferenced
  if (status);
}

Recommended

void func(const bool *status) {
  // seems intentional
  if (status && *status);
}

or

void func(const bool *status) {
  // seems intentional
  if (status)
    std::cout << "Status: " << *status << "std::endl";
}