Bug 403193

Summary: rule-of-three warns when it should not
Product: [Developer tools] clazy Reporter: Albert Astals Cid <aacid>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: normal CC: smartins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Said file

Description Albert Astals Cid 2019-01-13 22:48:17 UTC
Created attachment 117449 [details]
Said file

The attached code complains with 
   A has dtor, copy-ctor but not copy-assignment [-Wclazy-rule-of-three]

But the  when trying to use the copy-assignment you get

‘A& A::operator=(const A&)’ is implicitly deleted because the default definition would be ill-formed:
 class A
       ^
main.cpp:8:7: error: non-static const member ‘APrivate* const A::d’, can’t use default assignment operator


So clazy should not warn?
Comment 1 Sergio Martins 2019-01-14 12:51:49 UTC
Git commit 9cc61f7f2626c50cb16b44657ce72961fe8b536c by Sergio Martins.
Committed on 14/01/2019 at 12:48.
Pushed by smartins into branch '1.4'.

rule-of-three: Work around implicitly deleted copy-ctor/assign

When a class has a const member there won't be compiler generated
copy members. The corresponding method decls are nullptr, so we can't
call isDeleted() on it. Couldn't find proper API to check this, so
check if the class has a const field.

M  +12   -4    src/checks/level2/rule-of-three.cpp
A  +21   -0    tests/rule-of-three/bug403193.cpp     [License: UNKNOWN]  *
A  +0    -0    tests/rule-of-three/bug403193.cpp.expected
M  +3    -0    tests/rule-of-three/config.json

The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


https://commits.kde.org/clazy/9cc61f7f2626c50cb16b44657ce72961fe8b536c