[clazy] [Bug 438027] New: copyable-polymorphic should not issue a warning when the base class copy ctor isn't public
David Faure
bugzilla_noreply at kde.org
Thu Jun 3 11:55:00 BST 2021
https://bugs.kde.org/show_bug.cgi?id=438027
Bug ID: 438027
Summary: copyable-polymorphic should not issue a warning when
the base class copy ctor isn't public
Product: clazy
Version: unspecified
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: general
Assignee: unassigned-bugs at kde.org
Reporter: faure at kde.org
CC: smartins at kde.org
Target Milestone: ---
SUMMARY
copyable-polymorphic gives unfixable warnings when using a protected copy
constructor in the base class, and clone() virtual methods in subclasses. Or
final subclasses that can't be derived from. Copying is "safe" in such cases,
except when slicing *this internally, but we can't do anything about that.
Well, that would be for a different check: detecting actual slicing at the time
it happens... but for library authors, I guess this check still makes sense, if
it only warns for *public* copy constructors.
STEPS TO REPRODUCE
1. cd training-material/addon/cpp11/misc/sol-modernize; mkdir build-clazy
2. cmake .. -DCMAKE_CXX_COMPILER=clazy
3. export CLAZY_CHECKS='copyable-polymorphic'
4. make
OBSERVED RESULT
/d/kdab/src/training-material/addon/cpp11/misc/sol-modernize/modernize.cpp:22:1:
warning: Polymorphic class Person is copyable. Potential slicing.
[-Wclazy-copyable-polymorphic]
class Person
^
/d/kdab/src/training-material/addon/cpp11/misc/sol-modernize/modernize.cpp:46:1:
warning: Polymorphic class Employee is copyable. Potential slicing.
[-Wclazy-copyable-polymorphic]
class Employee : public Person
^
2 warnings generated.
EXPECTED RESULT
No such warning when the base class' copy constructor is protected
SOFTWARE/OS VERSIONS
clazy git master from today
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Unassigned-bugs
mailing list