Bug 411323

Summary: kdevelop-5.4.1/plugins/clang/duchain/unknowndeclarationproblem.cpp:144:44: warning: Possible dereference of an invalid iterator: x
Product: [Applications] kdevelop Reporter: dcb314
Component: generalAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal CC: kossebau
Priority: NOR    
Version First Reported In: 5.4.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description dcb314 2019-08-26 16:56:25 UTC
SUMMARY

Source code is

    for(auto x = a.begin(), y = b.begin(); *x == *y && x != a.end() && y != b.end() ; ++x, ++y ) {

Maybe better code

    for(auto x = a.begin(), y = b.begin(); x != a.end() && y != b.end() && *x == *y; ++x, ++y ) {

STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Friedrich W. H. Kossebau 2019-08-26 17:12:24 UTC
Thanks for the patch, makes sense to me.

By what "author <email>" would you like to be referred to when committing this patch?
Comment 2 dcb314 2019-08-26 19:34:15 UTC
Thanks for giving me the choice.

David Binderman <dcb314@hotmail.com> is fine.

Since you've replied quickly, I'll have a look at more kdevelop
messages from cppcheck and report any that look like proper bugs.
Comment 3 Friedrich W. H. Kossebau 2019-08-26 20:47:17 UTC
Git commit 69e1ed669289a6927d2cf3e3b7096a649a095d8c by Friedrich W. H. Kossebau, on behalf of David Binderman.
Committed on 26/08/2019 at 20:32.
Pushed by kossebau into branch '5.4'.

Avoid possible dereference of an invalid iterator

M  +1    -1    plugins/clang/duchain/unknowndeclarationproblem.cpp

https://invent.kde.org/kde/kdevelop/commit/69e1ed669289a6927d2cf3e3b7096a649a095d8c