stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek" <>
Subject RE: [PATCH] Add overflow checking to basic_string append and push_back
Date Thu, 20 Sep 2007 23:51:17 GMT

Martin Sebor wrote:
>Travis Vitek wrote:
>> template <class _TypeT>
>> class Xallocator
>> {
>> public:
>>     typedef unsigned char       size_type;
>I suspect the problem might actually be here. Once you define
>size_type to a type with a more generous range the test case
>passes. I made this and a few other simplifying changes in
>the attached program (it's also possible that I messed
>something up in the process ;-)

[ p4] Effects: Determines the effective length rlen of the
string to append as the smaller of n and str.size() - pos. The function
then throws length_error if size() >= npos - rlen.

The append that I'm invoking is described to behave as if it had called
that function. The attached test case shows that we are not following
through on that requirement.

>I agree that this is at least a theoretical problem (I can't
>quite imagine a practical use case for size_type being only
>8 bits wide). It might be an interesting exercise to change
>string (and the other containers) to work correctly even
>with size_type this small so long as it doesn't pessimize
>the common case in any way (i.e., I wouldn't be in favor
>of introducing a whole bunch of layers of template
>metaprogramming tricks to get this to work).

I can't imagine why you'd want size_type to be so small either, but the
fact is that the library allows you to do it, and it lists requirements
for the behavior.

>But back to your patch, unless it actually addresses this
>problem, we still need a test case for the problem that it
>does attempt to fix.

I agree. I was sure this was an actual problem. If it is deemed to not
be an issue, then I'm happy to let it slide.



  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message