* "basic_string" problem in libstdc++ @ 1997-10-09 15:14 Fred Richardson 1997-10-09 16:40 ` H.J. Lu 0 siblings, 1 reply; 5+ messages in thread From: Fred Richardson @ 1997-10-09 15:14 UTC (permalink / raw) To: egcs, egcs-bugs It looks like basic_string is broken: %> cat foo.cc // #define NO_STRING #include <stdlib.h> #include <std.h> #include <stdlib.h> #include <iostream.h> #include <fstream.h> #include <string> //================================================================== // main() // // Program's main routine. //================================================================== int main(int argc, char *argv[]) { for (int i = 0; i < argc; i++) { #ifndef NO_STRING string astr; const char* str = argv[i]; #else const char* str = argv[i]; #endif cout << "ARG " << i << ": " << str << endl; #ifndef NO_STRING astr = str; #endif } return 0; } %> g++ -v -o foo -Wall -g foo.cc Reading specs from /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/specs gcc version egcs-2.90.12 971008 (gcc2-970802 experimental) /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dsun -Dsparc -Dunix -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun__ -D__sparc__ -D__unix__ -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun -D__sparc -D__unix -Asystem(unix) -Asystem(svr4) -Acpu(sparc) -Amachine(sparc) -D__EXCEPTIONS -g -Wall foo.cc /var/tmp/cca006Ms.ii GNU CPP version egcs-2.90.12 971008 (gcc2-970802 experimental) (sparc) #include "..." search starts here: #include <...> search starts here: /d4mutl/contrib/egcs/include/g++ /usr/local/include /d4mutl/contrib/egcs/sparc-sun-solaris2.5.1/include /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/include /usr/include End of search list. /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/cc1plus /var/tmp/cca006Ms.ii -quiet -dumpbase foo.cc -g -Wall -version -o /var/tmp/cca006Ms.s GNU C++ version egcs-2.90.12 971008 (gcc2-970802 experimental) (sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.90.12 971008 (gcc2-970802 experimental). /d4mutl/contrib/egcs/sparc-sun-solaris2.5.1/bin/as -V -Qy -s -o /var/tmp/cca006Ms1.o /var/tmp/cca006Ms.s GNU assembler version 2.8 (sparc-sun-solaris2.5.1), using BFD version 2.8 /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/ld -V -Y P,/usr/ccs/lib:/usr/lib -Qy -o foo /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crt1.o /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crti.o /usr/ccs/lib/values-Xa.o /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crtbegin.o -L/d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12 -L/d4mutl/contrib/egcs/sparc-sun-solaris2.5.1/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/d4mutl/contrib/egcs/lib /var/tmp/cca006Ms1.o -lstdc++ -lm -lgcc -lc -lgcc /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crtend.o /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crtn.o GNU ld version 2.8 (with BFD 2.8) Supported emulations: elf32_sparc %> foo ARG 0: foo Segmentation fault %> g++ -DNO_STRING -v -o foo -Wall -g foo.cc Reading specs from /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/specs gcc version egcs-2.90.12 971008 (gcc2-970802 experimental) /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dsun -Dsparc -Dunix -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun__ -D__sparc__ -D__unix__ -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun -D__sparc -D__unix -Asystem(unix) -Asystem(svr4) -Acpu(sparc) -Amachine(sparc) -D__EXCEPTIONS -g -Wall -DNO_STRING foo.cc /var/tmp/cca006Mz.ii GNU CPP version egcs-2.90.12 971008 (gcc2-970802 experimental) (sparc) #include "..." search starts here: #include <...> search starts here: /d4mutl/contrib/egcs/include/g++ /usr/local/include /d4mutl/contrib/egcs/sparc-sun-solaris2.5.1/include /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/include /usr/include End of search list. /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/cc1plus /var/tmp/cca006Mz.ii -quiet -dumpbase foo.cc -g -Wall -version -o /var/tmp/cca006Mz.s GNU C++ version egcs-2.90.12 971008 (gcc2-970802 experimental) (sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.90.12 971008 (gcc2-970802 experimental). /d4mutl/contrib/egcs/sparc-sun-solaris2.5.1/bin/as -V -Qy -s -o /var/tmp/cca006Mz1.o /var/tmp/cca006Mz.s GNU assembler version 2.8 (sparc-sun-solaris2.5.1), using BFD version 2.8 /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/ld -V -Y P,/usr/ccs/lib:/usr/lib -Qy -o foo /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crt1.o /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crti.o /usr/ccs/lib/values-Xa.o /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crtbegin.o -L/d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12 -L/d4mutl/contrib/egcs/sparc-sun-solaris2.5.1/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/d4mutl/contrib/egcs/lib /var/tmp/cca006Mz1.o -lstdc++ -lm -lgcc -lc -lgcc /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crtend.o /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.12/crtn.o GNU ld version 2.8 (with BFD 2.8) Supported emulations: elf32_sparc %> foo ARG 0: foo %> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "basic_string" problem in libstdc++ 1997-10-09 15:14 "basic_string" problem in libstdc++ Fred Richardson @ 1997-10-09 16:40 ` H.J. Lu 0 siblings, 0 replies; 5+ messages in thread From: H.J. Lu @ 1997-10-09 16:40 UTC (permalink / raw) To: frichard; +Cc: egcs, egcs-bugs > > > It looks like basic_string is broken: > Have you been able to pass "make check" on tstring? I couldn't. And the 970929's patch on tstring.cc, which is enclosed here, looks pretty much bogus to me. I cannot find a matching basic_string constructor for string is (ar, ar+sizeof(ar)/sizeof(ar[0])); nor a matching replace memeber function for x.replace (find (x.begin (), x.end (), 'l'), find (x.rbegin (), x.rend (), 'l').base (), ar, ar+sizeof(ar)/sizeof(ar[0])); Am I missing something? Thanks. H.J. -- Index: tstring.cc =================================================================== RCS file: /home/work/cvs/gnu/egcs/libstdc++/tests/tstring.cc,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -r1.1.1.1 -r1.1.1.2 --- tstring.cc 1997/08/26 00:21:29 1.1.1.1 +++ tstring.cc 1997/10/01 19:56:05 1.1.1.2 @@ -14,8 +14,9 @@ // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to the Free // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + #include <string> +#include <algorithm> #include <iostream.h> #include <stdlib.h> #include <assert.h> @@ -65,6 +66,10 @@ assert(i == 20); assert(f == 20); + int ar[] = { 'H', 'e', 'l', 'l', 'o' }; + string is (ar, ar+sizeof(ar)/sizeof(ar[0])); + cout << "is = " << is << endl; + assert (is == "Hello"); } void cattest() @@ -142,6 +147,13 @@ x.replace (0, 1, 'j'); cout << "x.replace (0, 1, 'j'); x = " << x << "\n"; assert(x == "jello"); + + int ar[] = { 'H', 'e', 'l', 'l', 'o' }; + x.replace (find (x.begin (), x.end (), 'l'), + find (x.rbegin (), x.rend (), 'l').base (), + ar, ar+sizeof(ar)/sizeof(ar[0])); + cout << "x = " << x << endl; + assert (x == "jeHelloo"); } void iotest() ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "basic_string" problem in libstdc++ @ 1997-10-10 7:00 Max Lawson 0 siblings, 0 replies; 5+ messages in thread From: Max Lawson @ 1997-10-10 7:00 UTC (permalink / raw) To: egcs Hi ! Did someone succeed in using 971008-basic_string-stuff on a ix86 box? If so, can you send me your config (libc-version, bootstrap-options ...)? Thanx in advance. Max ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <199710091746.NAA26054.cygnus.egcs@bluebell.bbn.com>]
* Re: "basic_string" problem in libstdc++ [not found] <199710091746.NAA26054.cygnus.egcs@bluebell.bbn.com> @ 1997-10-10 9:22 ` Jason Merrill 1997-10-10 10:51 ` Mumit Khan 0 siblings, 1 reply; 5+ messages in thread From: Jason Merrill @ 1997-10-10 9:22 UTC (permalink / raw) To: frichard, egcs, egcs-bugs Here's a fix: Thu Oct 9 23:24:36 1997 Jason Merrill <jason@yorick.cygnus.com> * stdexcepti.cc (__out_of_range): New fn. (__length_error): New fn. * std/bastring.h (OUTOFRANGE): Fix logic. Use throwing functions. (LENGTHERROR): Likewise. Revert Oct 2 changes. * string: Revert Oct 2 changes. Index: stdexcepti.cc =================================================================== RCS file: /cvs/cvsfiles/devo/libstdc++/stdexcepti.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** stdexcepti.cc 1996/09/25 01:02:19 1.2 --- stdexcepti.cc 1997/10/10 06:57:31 1.3 *************** *** 6,8 **** --- 6,21 ---- #endif #include <stdexcept> + + // Entry points for string. + + void + __out_of_range (const char *s) + { + throw out_of_range (s); + } + + void __length_error (const char *s) + { + throw length_error (s); + } Index: string =================================================================== RCS file: /cvs/cvsfiles/devo/libstdc++/string,v rcsdiff: /cvs/cvsfiles/devo/libstdc++/string,v: warning: Unknown phrases like `dead ...;' are present. retrieving revision 1.6 retrieving revision 1.7 diff -c -r1.6 -r1.7 *** string 1997/10/02 17:26:27 1.6 --- string 1997/10/10 06:57:32 1.7 *************** *** 5,8 **** --- 5,13 ---- #include <std/bastring.h> + extern "C++" { + typedef basic_string <char> string; + // typedef basic_string <wchar_t> wstring; + } // extern "C++" + #endif Index: std/bastring.h =================================================================== RCS file: /cvs/cvsfiles/devo/libstdc++/std/bastring.h,v retrieving revision 1.32 retrieving revision 1.33 diff -c -r1.32 -r1.33 *** std/bastring.h 1997/10/02 17:26:30 1.32 --- bastring.h 1997/10/10 06:57:33 1.33 *************** *** 40,45 **** --- 40,63 ---- #include <iterator> + #ifdef __STL_USE_EXCEPTIONS + + extern void __out_of_range (const char *); + extern void __length_error (const char *); + + #define OUTOFRANGE(cond) \ + do { if (cond) __out_of_range (#cond); } while (0) + #define LENGTHERROR(cond) \ + do { if (cond) __length_error (#cond); } while (0) + + #else + + #include <cassert> + #define OUTOFRANGE(cond) assert (!(cond)) + #define LENGTHERROR(cond) assert (!(cond)) + + #endif + template <class charT, class traits = string_char_traits<charT> > class basic_string { *************** *** 262,269 **** reference operator[] (size_type pos) { unique (); return (*rep ())[pos]; } ! inline reference at (size_type pos); ! inline const_reference at (size_type pos) const; private: void terminate () const --- 280,295 ---- reference operator[] (size_type pos) { unique (); return (*rep ())[pos]; } ! reference at (size_type pos) ! { ! OUTOFRANGE (pos >= length ()); ! return (*this)[pos]; ! } ! const_reference at (size_type pos) const ! { ! OUTOFRANGE (pos >= length ()); ! return data ()[pos]; ! } private: void terminate () const *************** *** 358,398 **** static Rep nilRep; charT *dat; }; - - typedef basic_string <char> string; - // typedef basic_string <wchar_t> wstring; - - #ifdef __STL_USE_EXCEPTIONS - - #include <stdexcept> - #define OUTOFRANGE(cond) \ - do { if (!(cond)) throw out_of_range (#cond); } while (0) - #define LENGTHERROR(cond) \ - do { if (!(cond)) throw length_error (#cond); } while (0) - - #else - - #include <cassert> - #define OUTOFRANGE(cond) assert (!(cond)) - #define LENGTHERROR(cond) assert (!(cond)) - - #endif - - template <class charT, class traits> - inline basic_string <charT, traits>::reference - basic_string <charT, traits>::at (size_type pos) - { - OUTOFRANGE (pos >= length ()); - return (*this)[pos]; - } - - template <class charT, class traits> - inline basic_string <charT, traits>::const_reference - basic_string <charT, traits>::at (size_type pos) const - { - OUTOFRANGE (pos >= length ()); - return data ()[pos]; - } #ifdef __STL_MEMBER_TEMPLATES template <class charT, class traits> template <class InputIterator> --- 384,389 ---- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "basic_string" problem in libstdc++ 1997-10-10 9:22 ` Jason Merrill @ 1997-10-10 10:51 ` Mumit Khan 0 siblings, 0 replies; 5+ messages in thread From: Mumit Khan @ 1997-10-10 10:51 UTC (permalink / raw) To: Jason Merrill; +Cc: egcs, egcs-bugs Jason Merrill <jason@cygnus.com> writes: > Here's a fix: > Thanks. It seems to have fixed the basic_string problems. libstdc++ checks now pass on a i386-linux-gnulibc1. Mumit ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-10-10 10:51 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-10-09 15:14 "basic_string" problem in libstdc++ Fred Richardson 1997-10-09 16:40 ` H.J. Lu 1997-10-10 7:00 Max Lawson [not found] <199710091746.NAA26054.cygnus.egcs@bluebell.bbn.com> 1997-10-10 9:22 ` Jason Merrill 1997-10-10 10:51 ` Mumit Khan
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).