diff options
author | corvid, Sebastian Geerken <devnull@localhost> | 2014-07-19 11:57:39 +0200 |
---|---|---|
committer | corvid, Sebastian Geerken <devnull@localhost> | 2014-07-19 11:57:39 +0200 |
commit | f2a6892bc240c3a177ea98de50467b74f3fb18b7 (patch) | |
tree | ec2d4f19116f2f47c67ca2fe4a080335e6e052b3 | |
parent | 627abe06cd649cbd42dca9883e2c0a1e2b3ee9b0 (diff) |
Fixed compiler warning.
-rw-r--r-- | dw/textblock.cc | 14 | ||||
-rw-r--r-- | lout/misc.hh | 14 |
2 files changed, 15 insertions, 13 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc index beb3f3f8..123b5b40 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2655,19 +2655,9 @@ void Textblock::breakAdded () // actual width (Word::totalWidth) would include the space, so that // the width of the line is larger than the available width. - // Casting words->size() to long avoids the compiler warning - // - // "assuming signed overflow does not occur when assuming that - // (X - c) > X is always false [-Wstrict-overflow]" - // - // With long, the assumtion (X - c) > X (with X = words->size() and - // c = 2) is indeed always false. - // - // Let me know if you know a better solution. --SG - if (words->size () >= 2) - words->getRef((long)words->size () - 2)->origSpace = - words->getRef((long)words->size () - 2)->effSpace = 0; + words->getRef(words->size () - 2)->origSpace = + words->getRef(words->size () - 2)->effSpace = 0; } /** diff --git a/lout/misc.hh b/lout/misc.hh index 3082f33c..5aafd018 100644 --- a/lout/misc.hh +++ b/lout/misc.hh @@ -429,7 +429,19 @@ public: assert (i >= 0); return this->arrayMain + i; } else if (i >= this->startExtra + this->numExtra) { - assert (i < this->numMain + this->numExtra); + // The original assertion + /// + // "assert (i < this->numMain + this->numExtra)" + // + // causes this warnung in dw::Textblock::breakAdded: + // + // "assuming signed overflow does not occur when assuming that + // (X - c) > X is always false [-Wstrict-overflow]" + // + // Subtracting numExtra from both sides solves this, + // interrestingly. + + assert (i - this->numExtra < this->numMain); return this->arrayMain + i - this->numExtra; } else return this->arrayExtra1 + i - this->startExtra; |