Let's say I have the following code:
std::vector< int > from( 5 );
std::vector< int > to( 10 );
std::copy( from.begin(), from.begin() + 10, to.begin() );
or it maybe
std::vector< int >::iterator e = from.begin();
std::advance( e, 10 );
std::copy( from.begin(), e, to.begin() );
when I ran it with Visual Studio in Debug mode I got an assert failed with text "iterator is out of range". When I ran it with GCC - LWS link - I got nothing, but incorrect working.
Now the question: is there GCC option to switch on run-time comparing iterators for correct range and either to throw appropriate exception or to call assert
if iterator is out of range.
P.S. I clearly know, that code is incorrect and maybe has UB. And I know how to correct it, but I want GCC to help me in future ))