Removed undefined behaviour when iterating backwards when using pointers.

This commit is contained in:
Ion Gaztañaga
2016-08-05 00:46:01 +02:00
parent 5a7892a859
commit ef8e57ae1b
2 changed files with 7 additions and 7 deletions

View File

@@ -76,11 +76,11 @@ int main()
//Now test lists
List::const_iterator list_it (my_list.cbegin());
identifier_t *it_val(&ids[NumElements-1]), *it_rbeg_val(&ids[0]-1);
identifier_t *it_val(&ids[NumElements]), *it_rbeg_val(&ids[0]);
//Test the objects inserted in the base hook list
for(; it_val != it_rbeg_val; --it_val, ++list_it)
if(&*list_it != &*it_val) return 1;
if(&*list_it != &it_val[-1]) return 1;
return 0;
}