Bug 326243

Summary: libs/kotext/styles/KoCharacterStyle.cpp:1938:42: warning: iteration 3u invokes undefined behavior
Product: [Applications] calligracommon Reporter: Dennis Schridde <dschridde+kde>
Component: generalAssignee: Calligra Bugs <calligra-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 2.7.4   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Dennis Schridde 2013-10-18 22:38:56 UTC
GCC 4.8 says:
---
calligra-2.7.4/libs/kotext/styles/KoCharacterStyle.cpp:1938:42: warning: iteration 3u invokes undefined behavior [-Waggressive-loop-optimizations]
---

The code is:
---
    for (unsigned int i = 0; i < sizeof(keepProperties); ++i) {
        if (hasProperty(keepProperties[i])) {
            keep.insert(keepProperties[i], value(keepProperties[i]));
---

It should be: i < sizeof(keepProperties)/sizeof(*keepProperties)

Reproducible: Always
Comment 1 Camilla Boemann 2013-11-10 11:47:59 UTC
Git commit 50a16640316616c3ce7562a6792bdc82ce11b9e5 by C. Boemann.
Committed on 10/11/2013 at 11:42.
Pushed by boemann into branch 'master'.

Fix unsafe looping

thanks Dennis for report and solution suggestion

M  +1    -1    libs/kotext/styles/KoCharacterStyle.cpp

http://commits.kde.org/calligra/50a16640316616c3ce7562a6792bdc82ce11b9e5
Comment 2 Halla Rempt 2013-11-22 10:56:53 UTC
Git commit 8c429e7585168e613440d07228c756109de8f2e2 by Boudewijn Rempt, on behalf of C. Boemann.
Committed on 10/11/2013 at 11:42.
Pushed by rempt into branch 'calligra/2.7'.

Fix unsafe looping

thanks Dennis for report and solution suggestion

M  +1    -1    libs/kotext/styles/KoCharacterStyle.cpp

http://commits.kde.org/calligra/8c429e7585168e613440d07228c756109de8f2e2