Skip to main content
ai-slop/cpp-iostream-leftovermanual fix

iostream leftover.

`std::cout` or `std::cerr` in library code. Usually debug output that shipped.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

cpp-iostream-leftover.cpp
✗ Flagged
Matrix Matrix::inverse() const {
    std::cout << "inverting " << rows_ << "x" << cols_ << "\n";
    Matrix result = decompose();
    std::cerr << "det=" << determinant() << "\n";
    return result;
}
Why this trips

Deterministic line match on masked source: flags `std::cout` and `std::cerr` in C and C++ files that do not define `int main(`.

cpp-iostream-leftover.cpp
✓ Clean
Matrix Matrix::inverse() const {
    if (determinant() == 0.0) {
        throw SingularMatrixError(rows_, cols_);
    }
    return decompose();
}
What changed

Remove the debug output, or route it through the project's logging facility.

Agents print intermediate values to check their work and leave the stream writes behind. In a library they go to whatever stdout the host process has.

How this rule is justified.

Rule id

ai-slop/cpp-iostream-leftover

Enforcing engine

ai-slop

Detector strategy

Deterministic line match on masked source: flags `std::cout` and `std::cerr` in C and C++ files that do not define `int main(`.

Legitimate code that is NOT flagged

Files that contain `main`, test files, output routed through a logging facility, and unqualified `cout` after a using-directive are not flagged.

Evidence

Part of aislop's C/C++ rule set. C/C++ support, including C/C++-specific AI-slop rules, arrived in aislop v0.14.1.