Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A27-0-4: C-Style (and arrays) detected when logging in assert or using the hash/stringize operator in a macro #772

Open
fjatWbyT opened this issue Oct 22, 2024 · 0 comments
Labels
false positive/false negative An issue related to observed false positives or false negatives. Standard-AUTOSAR

Comments

@fjatWbyT
Copy link
Contributor

Affected rules

  • A27-0-4
  • A18-1-1

Description

Alerts of both rules are triggered even if no C-style array or string is directly used. It may also be relevant that the usage of the # operator is covered by rule M16-3-2.

Example

#include <cassert>

#define ASSERT(expr) ((expr) ? static_cast<void>(0) : [] { assert(false && #expr); }())

class a_class
{
  public:
    void some_operator()
    {
        ASSERT(flag_);
    }

  private:
    bool flag_ = false;
};

int main()
{
    assert((false) && "A way to add an assert message");
    a_class instance;
    instance.some_operator();
}

A27-0-4 and A18-1-1 alerts are signaled on ASSERT(flag_); as well as assert((false) && "A way ... message");

@fjatWbyT fjatWbyT added the false positive/false negative An issue related to observed false positives or false negatives. label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false positive/false negative An issue related to observed false positives or false negatives. Standard-AUTOSAR
Projects
None yet
Development

No branches or pull requests

2 participants