This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ctor_copy_dtor test allocates ridiculous amounts of memory


> where csz01 has been initialized to str01.max_size().  Flipping
> through basic_string.h, it looks like that's a constant equal to
> one-quarter the max virtual address space - 1GB in this case.

right

this is the full test block, in context you can see what the test is 
doing:

  // Build a maxsize-1 lengthed string consisting of all A's
  try {
    std::string str03(csz01 - 1, 'A');
    VERIFY( str03.size() == csz01 - 1 );
    VERIFY( str03.size() <= str03.capacity() );
  }              
  // NB: bad_alloc is regrettable but entirely kosher for
  // out-of-memory situations.
  catch(std::bad_alloc& fail) {
    VERIFY( true );
  }
  catch(...) {
    VERIFY( false );
  }

this test did end up passing for you, correct?

> My question to you, then, is - is that a sensible upper limit?  And is
> it sensible to actually create a string of that size during testing?

as a pathological corner case, this is legitimate. 

as for your second question: is it sensible to allocate this kind of 
memory during testing? I've always thought it ok to test stuff like this 
(ie pathological cases) but perhaps I'm off base.

-benjamin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]