stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-272) std::string::find_first_of() returns 0 for the empty string
Date Tue, 27 Feb 2007 17:53:05 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12476245
] 

Farid Zaripov commented on STDCXX-272:
--------------------------------------

I can't repeat the issue.

The test aborts within find_first_of() method due to _RWSTD_REQUIRES (__n <= max_size (),)
macro.

Here __n is std::string::npos, but max_size() returns value less than std::string::npos.

Another point: is that std::string::npos can be used in find_first_of() call?

The standard says that n should be less than npos:

21.3.7.3
size_type
find_first_of(const charT* s , size_type pos , size_type n ) const;
4 Returns: find_first_of(basic_string<charT,traits,Allocator>(s ,n ),pos ).

21.3.2
basic_string(size_type n , charT c , const Allocator& a = Allocator());
11 Requires: n < npos

> std::string::find_first_of() returns 0 for the empty string
> -----------------------------------------------------------
>
>                 Key: STDCXX-272
>                 URL: https://issues.apache.org/jira/browse/STDCXX-272
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3, 4.1.2
>         Environment: all
>            Reporter: Martin Sebor
>         Assigned To: Martin Sebor
>
> The program below is expected to run succeffully to completion (since the returned value
must be less than the size of the string) but instead it aborts.
> $ cat t.cpp && nice gmake t && ./t
> #include <cassert>
> #include <string>
> int main ()
> {
>     std::string::size_type xpos =
>         std::string ("").find_first_of ("cba", 0, std::string::npos);
>     assert (std::string::npos == xpos);
> }
> aCC -c -I/amd/devco/sebor/dev/stdlib/include/ansi -I/usr/include  -D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG
-I/amd/devco/sebor/dev/stdlib/include -I/build/sebor/aCC-3.70-11d/include -I/amd/devco/sebor/dev/stdlib/examples/include
 -Aa +nostl  -g +d  +w +W392 +W655 +W684 +W818 +W819 +W849  t.cpp
> aCC t.o -o t -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L/build/sebor/aCC-3.70-11d/lib
   -L/build/sebor/aCC-3.70-11d/lib -lstd11d   -lm
> ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message