[
https://issues.apache.org/jira/browse/STDCXX-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12476401
]
Martin Sebor commented on STDCXX-272:
-------------------------------------
You just did (reproduce it): it aborted for you as well :)
To answer your question: max_size() is a valid argument to find_first_of
because there is no text that says is it isn't.
The requirement you cite (that n should be less than npos) applies to to the
string ctor in 21.3.2 but not to find_first_of. Returns clauses impose only one
requirement: on the value returned by the function (see
[structure.specifications]). Requirements on the observable side-effects of
function calls (such as calls to other, for instance virtual, functions), are
imposed by Effects clauses. The requirements on exceptions to be thrown are
typically imposed by Throws clauses (although an Effects clause may impose the
same requirement if the called function throws).
I filed a new issue for this some time ago. See:
http://home.twcny.rr.com/hinnant/cpp_extensions/issues_preview/lwg-active.html#625
It's not on the official LWG issues list yet but it will be in the next mailing
(in about two weeks).
> 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.