| Summary: | CharacterColor.h != and == implementation causing alignment trap on ARM (and probably other) processors (x86 not affected) | ||
|---|---|---|---|
| Product: | [Applications] konsole | Reporter: | Alessandro Briosi <tsdogs> |
| Component: | general | Assignee: | Konsole Bugs <konsole-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Compiled Sources | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
Forgot to mention the file: File is CharacterColor.h Hi, I didn't write that code myself but it seems to me that it is unnecessary to have them at all. Alignment problem aside, the operator==() and operator!=() methods are equivalent to the built-in defaults which the compiler generates. > Alignment problem aside, the operator==() and operator!=() methods
> are equivalent to the built-in defaults which the compiler generates.
Sorry, moment of stupidity, I was thinking of operator=(). An alterative would be to use memcmp() in operator==() and then define operator!=() as !operator==().
SVN commit 792018 by knight: Re-write CharacterColor::operator==(), CharacterColor::operator!=(). Previous implementation caused memory alignment trap on ARM. BUG:160137 M +2 -5 CharacterColor.h WebSVN link: http://websvn.kde.org/?view=rev&revision=792018 SVN commit 792019 by knight: Compare CharacterColor members explicitly rather than using memcpy for clarity. CCBUG: 160137 M +4 -1 CharacterColor.h WebSVN link: http://websvn.kde.org/?view=rev&revision=792019 |
Version: 2.0 up (using Devel) Installed from: Compiled sources Compiler: gcc-4.1.2 Porting konsole4 to Qtopia made me find this bug, which I think should be fixed. OS: Linux The current implementation of the inline bool operators != and == causes an alignment trap on arm cpu. It's not memory alignment safe. I found this porting konsole 2 to Qtopia. Current implementation: --------------------------------------- inline bool operator == (const CharacterColor& a, const CharacterColor& b) { return *reinterpret_cast<const quint32*>(&a._colorSpace) == *reinterpret_cast<const quint32*>(&b._colorSpace); } inline bool operator != (const CharacterColor& a, const CharacterColor& b) { return *reinterpret_cast<const quint32*>(&a._colorSpace) != *reinterpret_cast<const quint32*>(&b._colorSpace); } proposed new implementation fixing the problem and memory alignemnt safe: ------------------------------------------------- inline bool operator == (const CharacterColor& a, const CharacterColor& b) { return (a._colorSpace == b._colorSpace && a._u == b._u && a._v == b._v && a._w == b._w); } inline bool operator != (const CharacterColor& a, const CharacterColor& b) { return (a._colorSpace != b._colorSpace || a._u != b._u || a._v != b._v || a._w != b._w); }