public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13084] New: class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour
@ 2003-11-17 10:13 ronald dot van dot uden at rabobank dot com
2003-11-17 14:17 ` [Bug libstdc++/13084] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ronald dot van dot uden at rabobank dot com @ 2003-11-17 10:13 UTC (permalink / raw)
To: gcc-bugs
problem:
char* charPointerString = input;
while ((iPos = myStr.find(charPointerString, iPos)) != string::npos){}//an
infinite loop
workaround:
string myString(input);
while ((iPos = myStr.find(myString, iPos)) != string::npos){}//
gcc 2.95 and gcc 3.3 implementation difference of class string with find()
members
the string function
size_type string::find (const char* cstr, size_type idx) const
never finds the string it is looking for in gcc33 when cstr==""
the string function
size_type string::find(const string& str, size_type idx) const
works properly on gcc33 when str==""
______________________________________________________
the function find (const char* cstr, size_type idx) seems to work fine on
gcc2.95
Operating System: Sun Solaris9
--
Summary: class string with find(const char* cstr, size_type idx)
member have different gcc 2.95 and gcc 3.3 behaviour
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ronald dot van dot uden at rabobank dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13084
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/13084] class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour
2003-11-17 10:13 [Bug c++/13084] New: class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour ronald dot van dot uden at rabobank dot com
@ 2003-11-17 14:17 ` pinskia at gcc dot gnu dot org
2003-11-18 9:04 ` paolo at gcc dot gnu dot org
2003-11-18 9:58 ` paolo at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-17 14:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-11-17 14:17 -------
Can you provide a full testcase?
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Component|c++ |libstdc++
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13084
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/13084] class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour
2003-11-17 10:13 [Bug c++/13084] New: class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour ronald dot van dot uden at rabobank dot com
2003-11-17 14:17 ` [Bug libstdc++/13084] " pinskia at gcc dot gnu dot org
@ 2003-11-18 9:04 ` paolo at gcc dot gnu dot org
2003-11-18 9:58 ` paolo at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: paolo at gcc dot gnu dot org @ 2003-11-18 9:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From paolo at gcc dot gnu dot org 2003-11-18 09:04 -------
I strongly suspect submitter is thinking about this kind of testcase
#include <string>
#include <cassert>
int main()
{
std::string aaa = "Francesca";
char* lit = "";
assert( aaa.find(lit) == 0 );
std::string str("");
assert( aaa.find(str) == 0 );
}
What happens here, is that v2's find returns 9 whereas v3 returns 0 (for
both the tests)
Now, 9 is definitely wrong since is past the end of the string aaa and
find is supposed to return aither a valid index inside aaa or string::npos.
However, I'm not deadly sure that 0 is correct: just let me think a bit more
about the issue...
Paolo.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |ASSIGNED
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-11-18 09:04:49
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13084
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/13084] class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour
2003-11-17 10:13 [Bug c++/13084] New: class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour ronald dot van dot uden at rabobank dot com
2003-11-17 14:17 ` [Bug libstdc++/13084] " pinskia at gcc dot gnu dot org
2003-11-18 9:04 ` paolo at gcc dot gnu dot org
@ 2003-11-18 9:58 ` paolo at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: paolo at gcc dot gnu dot org @ 2003-11-18 9:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From paolo at gcc dot gnu dot org 2003-11-18 09:58 -------
On second tought, the true reason why 9 is not ok whereas 0 *is* ok is that,
according to the standard (21.3.6.1, p1): "determines the _lowest_ possible
xpos, if possible, such as both the following conditions..." (emphasis mine).
Now, "the following conditions" are fulfilled both by 0 and 9, and 0 is the
correct final answer. This is also consistent with the behavior for the general
str.find(lit, pos = 0), returning pos for lit == "" (when pos <= str.size(),
otherwise npos, of course).
I'm closing the report as not a bug.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13084
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-11-18 9:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-17 10:13 [Bug c++/13084] New: class string with find(const char* cstr, size_type idx) member have different gcc 2.95 and gcc 3.3 behaviour ronald dot van dot uden at rabobank dot com
2003-11-17 14:17 ` [Bug libstdc++/13084] " pinskia at gcc dot gnu dot org
2003-11-18 9:04 ` paolo at gcc dot gnu dot org
2003-11-18 9:58 ` paolo at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).