On attached test case GCC keeps the index range checks in Vector::getValue although they're always true due to loop conditions # GNU C++ (GCC) version 4.5.0 (mingw32) # options passed: -fpreprocessed yy5.ii -march=atom -mtune=atom -O2 -Wall
Created attachment 20538 [details] Test case foo() uses a get method without checks and is ok, checks not optimized away in bar()
Created attachment 20539 [details] Assembler listing
Well, this is another case where the predication by if (mData) makes this hard to optimize. Not impossible, but hard.