473,786 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,pasca l,objc,ada,tree lang --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 2222
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
3634
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 0.14.1, will using PHP's gettext support along with the GNU gettext utilities work properly? For example, I've seen references to the translated strings in .mo files not always being what appears
11
2348
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. Sometimes I just take the line number of the error and try to figure out myself what might be wrong. Or I just remember this error message and know already: if g++ says error X it really means error Y.
13
3967
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
1103
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, and something tells me it is a silly error, but I can't find it. Here is the part of the code where I get the errors: CD cd = (CD)supplies;
12
11347
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 suddenly stopped even opening ? but when i run it form bat with JAVA_CLIENT parameter it throws javax.ejb.EJBException: nested exception is: java.rmi.RemoteException: package library.common; import java.sql.ResultSet;
2
5913
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 no= numberinput.getText();
15
2185
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() { public void actionPerformed(ActionEvent e) { try{
2
2350
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 the connection from the DriverManager Connection con = DriverManager.getConnection(database ,"",""); //String searchPatients = G.PatientSearch.getText(); // We are connected, so lets create a statement to ask for...
1
2014
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 = DriverManager.getConnection(url2, username, password); Statement statement = connection.createStatement(); sql = "INSERT INTO medicalrecords (NRIC, Time, Diagnosis, MC, NoOfDays, Prescription1, Qty1, Prescription2, Qty2, Prescription3, Qty3, Prescription4, Qty4,...
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.