views:

24

answers:

0

The following code snippet compiles perfectly in debug mode, but fails with using optimisation. What is wrong with the second conditional expression?

#include <vector>
using namespace std;

int main (int argc, const char * argv[]) 
{
  typedef vector<int> IntVector;
  IntVector intVector;
  IntVector::const_iterator iter;

  if (iter != intVector.end())
  {
    @try { }
    @catch (NSException * e) { }
    @finally { }
  }

  if (iter != intVector.end())  // see error message
  {
  }

  return 0;
}

/Developer/usr/bin/gcc-4.2 -x objective-c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -Wreturn-type -Wunused-variable -isysroot /Developer/SDKs/MacOSX10.6.sdk -fvisibility=hidden -fvisibility-inlines-hidden -mmacosx-version-min=10.6 -gdwarf-2 /Volumes/Project/iterator_error/iterator_error.mm -o /Volumes/Project/iterator_error/build/iterator_error.build/Release/iterator_error.build/Objects-normal/i386/iterator_error.o

/Volumes/Project/iterator_error/iterator_error.mm: In function 'int main(int, const char**)': /Volumes/Project/iterator_error/iterator_error.mm:19: error: no match for 'operator!=' in 'iter != intVector. std::vector<_Tp, _Alloc>::end with _Tp = int, _Alloc = std::allocator'