This is the mail archive of the libstdc++@sourceware.cygnus.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: basic_string<>::max_size - only 1MB?



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


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