Bug 403193 - rule-of-three warns when it should not
Summary: rule-of-three warns when it should not
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-13 22:48 UTC by Albert Astals Cid
Modified: 2019-01-14 12:51 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Said file (407 bytes, text/x-c++src)
2019-01-13 22:48 UTC, Albert Astals Cid
Details

Note You need to log in before you can comment on or make changes to this bug.
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