This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: basic_string<>::max_size - only 1MB?
- To: libstdc++@sourceware.cygnus.com
- Subject: Re: basic_string<>::max_size - only 1MB?
- From: Nathan Myers <ncm@best.com>
- Date: Tue, 22 Jun 1999 13:22:19 -0700 (PDT)
Jason wrote:
>>>>> Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de> writes:
> > I think _Rep::_S_max_size should be increased to npos/40 (=100MB) or
> > so.
>
> Why not just (npos/sizeof(CharT)) - 1 ?
The correct value would be something like
((~(size_t)0)-sizeof(_Rep)-1)/sizeof(_CharT) - 2.
Trying to create a string close to that size evokes a fatal bug in
common implementations of malloc. Benjamin reduced max_size() to a
safe but unrealistically small value so his tests would run to
completion.
The definition probably should have been marked "XXX", with a note.
It may be that half the above-recommended value would be safe on more
systems. Ultimately it must be based on a Configure-discovered value,
assuming that Configure can discover it without crashing the whole
bug-ridden machine.
Nathan Myers
ncm@cantrip.org