[PATCH] Tighten length error check in string::replace

Benjamin Kosnik bkoz@redhat.com
Thu Apr 25 15:27:00 GMT 2002


> +void
> +test05()
> +{

bool test = true;

> +  std::string str01 = "beyond skin";
> +  std::string str02 = "glam";
> +
> +  try {
> +    str01.replace(8, 7, str02.c_str(), str02.max_size() - 4);
> +  }
> +  catch(std::length_error& fail) {
> +    VERIFY( std::string(fail.what()) == "basic_string::replace" );
> +  }
> +  catch(...) {
> +    VERIFY( false );
> +  }
> +}

Is this really correct behavior, to throw length_error here? I'm
uncertain.

-benjamin



More information about the Libstdc++ mailing list