473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Error, if compiled with -O3 (gettext)

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
2 2197
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave Patton | last post by:
Can someone point me to a definitive source for the answers to the following two questions: 1) In an environment with Redhat Linux 2.4.21-27.0.1, Apache 1.3.31, PHP 4.3.10, and GNU gettext...
11
by: Markus Dehmann | last post by:
I have started with C++ a few months ago. The language itself is nice, but what I really don't like are the error messages that I get from g++. g++ error messages are often just not helpful. ...
13
by: cantabile | last post by:
Hi, I'm failing to make it work but can't find out what's wrong. Here's what I do : ================ test.py import gettext gettext.install('')
1
by: lucky29105 | last post by:
Hello- I cant seem to figure out why I am getting the following error: cannot find symbol : class CD location: class Inventory5 CD cd = (CD)supplies; ^ I'm getting this on several lines,...
12
oll3i
by: oll3i | last post by:
when i launch the application from sun application server the console opens throws something i cannt even read what and closes before the application opened and threw nullpointerexception now it...
2
by: cypriot | last post by:
Hi. I am developing an application program in java. I use MsAccess for keeping data. I had a problem with sql insert method. public void AddPatient() { String...
15
by: cypriot | last post by:
Hi. I want to insert data to ms access from an application I developed in java but I think I have a prob with data types. This is my code. savebutton.addActionListener( new ActionListener()...
2
by: kierandes | last post by:
Hi Guy, I am using a JDBC connection to retrieve data and populate datasets. Having some problems with errors: Error: java.sql.SQLException: Invalid cursor state // now we can get...
1
by: carecare86 | last post by:
These are the codes. I cant see any error there. Please kindly help. Thanks. void saveMedicalRecords() { try { Class.forName(driver); Connection connection =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.