[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Compiler Optimization Error
From: Herbert Straub ####@####.#### Date: 26 May 2004 21:28:23 +0100 Message-Id: <40B4FD54.1010502@aon.at> Hallo, the following patch should remove the compiler error (-O3), see: http://www.linuxhacker.org/cgi-bin/ezmlm-cgi?9:mss:28:200403:bkfakbgciehfapklpnik Index: NServer-0.9.1/Article.h =================================================================== RCS file: /home/stb/products/newscache-new/my_cvs/NewsCache/NServer-0.9.1/Article.h,v retrieving revision 1.7 diff -u -r1.7 Article.h --- a/NServer-0.9.1/Article.h 5 Feb 2003 21:49:09 -0000 1.7 +++ b/NServer-0.9.1/Article.h 26 May 2004 19:52:20 -0000 @@ -69,7 +69,7 @@ } Article(Article * a) { _nbr = a->getnbr(); - _text = a->gettext(); + _text = a->mygettext(); _ctext = _text.c_str(); } Article(int artnbr) { @@ -105,7 +105,7 @@ int getnbr() const { return _nbr; - } string gettext() { + } string mygettext() { return _text; } const char *c_str() { Index: NServer-0.9.1/checks/cArticle.cc =================================================================== RCS file: /home/stb/products/newscache-new/my_cvs/NewsCache/NServer-0.9.1/checks/cArticle.cc,v retrieving revision 1.2 diff -u -r1.2 cArticle.cc --- a/NServer-0.9.1/checks/cArticle.cc 21 Jan 2003 22:59:28 -0000 1.2 +++ b/NServer-0.9.1/checks/cArticle.cc 26 May 2004 19:52:14 -0000 @@ -36,7 +36,7 @@ if (la1 != art1.length() || la1 != art2->length()) return -12; - art1.settext(art2->gettext()); + art1.settext(art2->mygettext()); if (strcmp(art1.c_str(), art2->c_str())) return -21; if (la1 != art1.length() || la1 != art2->length()) I think, the error situation can be reduced to the following simple test program: #include <string> #include <iostream> class foo { std::string s; public: foo (const char *a) : s(a) {}; std::string gettext (void) { return s; } }; int main (int argc, char **argv) { foo f("test"); std::string a; a=f.gettext(); std::cout << "Test: " << a << std::endl; return 0; } Compiled and linked with: g++ -o t1 t1.cxx ./t1 Test: test And now with -O3: g++ -O3 -o t1 t1.cxx t1.cxx:11: error: parse error before `,' token t1.cxx:11: error: variable declaration is not allowed here t1.cxx:11: error: syntax error before `{' token t1.cxx:12: error: parse error before `}' token t1.cxx: In function `int main(int, char**)': t1.cxx:19: error: parse error before `,' token t1.cxx:19: error: `dcgettext' undeclared (first use this function) t1.cxx:19: error: (Each undeclared identifier is reported only once for each function it appears in.) g++ -v Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux Thread model: posix gcc version 3.3.3 (Debian 20040401) And now the old compiler 2.95: g++-2.95 -O3 -o t1 t1.cxx ./t1 Test: test g++-2.95 -v Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs gcc version 2.95.4 20011002 (Debian prerelease) Herbert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |