By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,012 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

Error, if compiled with -O3 (gettext)

P: n/a
What could be wrong with this 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)
Thanks, Herbert
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Herbert Straub <he************@wienkav.at> writes:
What could be wrong with this simple test program:

#include <string>
#include <iostream>

class foo
{
std::string s;
public:
foo (const char *a) : s(a) {};
The semicolon after the body of the constructor should be removed, but
that is not the cause of the trouble.
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.)


Some header defines `gettext' as a macro.

The fact that this also happens when the compiler is invoked in standard
compliant mode (g++ -O3 -std=c++98 -pedantic -o t1 t1.cxx) is a compiler
bug. You should report it; please follow the instructions on how to
report bugs at <http://gcc.gnu.org/>.

Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-' `-'(. .)`-'
`-. Debian, a variant of the GNU operating system. \_/
Jul 22 '05 #2

P: n/a
Martin Dickopp wrote:
bug. You should report it; please follow the instructions on how to
report bugs at <http://gcc.gnu.org/>.


Done. Bugnumber: 15773
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.