Re: RFC: SBuf::find api

From: Kinkie <gkinkie_at_gmail.com>
Date: Wed, 27 Mar 2013 11:34:04 +0100

Hi all,
  according to the answers to a similar question on stackoverflow
(http://stackoverflow.com/questions/1011790/why-does-stdstring-findtext-stdstringnpos-not-return-npos),
it seems that the std::string behavior is not declared undefined; it's
simply not defined.

  The way I'm currently covering this is to remove this specific test
case from the automated testsuite and cover it instead with specific
manual tests; this is consistent with the fact that the API we define
are more detailed than the standard.
  Working around an inconsistent standard libarary is of course
doable, but more complex and IMVHO not really helpful.

On Tue, Mar 26, 2013 at 10:24 PM, Alex Rousskov
<rousskov_at_measurement-factory.com> wrote:
> On 03/24/2013 10:35 AM, Kinkie wrote:
>
>> digging up some documentation for the inconsistent behavior of
>> std::string::find() in GCC, it appears that its behavior is undefined
>> if the pos parameter is std::string::npos.
>
>> I'd like to define that behavior by making it explicit in the API that
>> SBuf::find (in any variant) when called with pos=SBuf::npos will
>> return SBuf::npos. This is consistent with recent gcc, but not with
>> the current implementation
>
> If the standard says the behavior is undefined, we should mimic what GCC
> implementation does. If GCC versions are inconsistent in this regard,
> your suggestion sounds good to me, especially if it matches latest GCC
> implementations.
>
> Please note that you may need to adjust test cases to accommodate this
> change if we want them to pass on all supported GCC versions and those
> versions are inconsistent.
>
>
> Thank you,
>
> Alex.
>
>
>

-- 
    /kinkie
Received on Wed Mar 27 2013 - 10:34:14 MDT

This archive was generated by hypermail 2.2.0 : Wed Mar 27 2013 - 12:00:25 MDT