https://bugs.kde.org/show_bug.cgi?id=379342

            Bug ID: 379342
           Summary: clazy-function-args-by-value false positive when ref
                    constructor arg is stored as ref in class
           Product: clazy
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: unassigned-b...@kde.org
          Reporter: markus.enzenber...@gmail.com
                CC: smart...@kde.org
  Target Milestone: ---

The following snippet creates a clazy-function-args-by-value warning even if it
is essential to use a reference since the class stores a copy of the reference.
If the user follows the recommendation by clazy, a bug is intruduced in the
code, which not every compiler will detect and warn about.

struct A
{
    const int& m_a;
    A(const int& a) : m_a(a) { }
};

I tested this with the current clazy from github (f5e6ccbc). Funnily enough,
clazy does not complain if a non-const reference is used for the member and the
argument.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to