diff options
author | frosch <frosch@openttd.org> | 2010-01-16 16:44:59 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-01-16 16:44:59 +0000 |
commit | 6101ad8396b5b5a9cc0e5090e867c131d86d911d (patch) | |
tree | e1d516f4cd2c28f42b816f0ebca47dc46f5edcd1 /src | |
parent | ff11095916537744e3683080c32e46f3c70f8416 (diff) | |
download | openttd-6101ad8396b5b5a9cc0e5090e867c131d86d911d.tar.xz |
(svn r18828) -Fix (r18823): Decrementing uints is different to ints.
Diffstat (limited to 'src')
-rw-r--r-- | src/misc/fixedsizearray.hpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/misc/fixedsizearray.hpp b/src/misc/fixedsizearray.hpp index 5d52c2881..fe7d6b012 100644 --- a/src/misc/fixedsizearray.hpp +++ b/src/misc/fixedsizearray.hpp @@ -78,8 +78,10 @@ public: /** Clear (destroy) all items */ FORCEINLINE void Clear() { - /* walk through all allocated items backward and destroy them */ - for (T *pItem = &data[Length() - 1]; pItem >= data; pItem--) { + /* Walk through all allocated items backward and destroy them + * Note: this->Length() can be zero. In that case data[this->Length() - 1] is evaluated unsigned + * on some compilers with some architectures. (e.g. gcc with x86) */ + for (T *pItem = this->data + this->Length() - 1; pItem >= this->data; pItem--) { pItem->~T(); } /* number of items become zero */ |