This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
Re: ctor_copy_dtor test allocates ridiculous amounts of memory
- To: Zack Weinberg <zackw at stanford dot edu>
- Subject: Re: ctor_copy_dtor test allocates ridiculous amounts of memory
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Sat, 7 Oct 2000 12:34:31 -0700 (PDT)
- cc: gcc-bugs at gcc dot gnu dot org, libstdc++ at sources dot redhat dot com
> 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