473,809 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

gnu optimization bug

Recently i found that my C++ program was running fine with no
optimization and giving segmentation fault with error code 139 when
compiled with optimization level 2. I searched somewhat but never find
any systematic solution. In my recent attempt, i found the problem with
the optimization tool itself, which iam discussing here.

I found that the problem of segmentation fault was boiled down to a
statement of the form A = B, with no pointer or array usage, so forget
about the illegal memory write problems. When i removed this statement,
the problem disappers, so concluded that the segmentation fault problem
is with this statement. A careful study revealed that this statement
was redundant because A was never used in the program after this
statement. So i inserted one more statement after the above statement
which is "X = A", where X is a dummy variable and in that case the
problem again disappears. Inserting this new statement has made my
initial statement no more redundant.

I think the optimization tool had detected that A = B is a redundant
statement but failed to do its work. So its a clear bug in the
optimization tool itself.

The gcc -v output of my system is following:

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++ ,java,f95,objc, ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.0 --enable-__cxa_atexit
--enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=releas e i486-linux-gnu
Thread model: posix
gcc version 4.0.2 (Debian 4.0.2-2)

May 31 '06 #1
3 2253

"Abhishek" <ab************ @gmail.com> wrote in message

| Recently i found that my C++ program was running fine with no
| optimization and giving segmentation fault with error code 139 when
| compiled with optimization level 2. I searched somewhat but never find
| any systematic solution. In my recent attempt, i found the problem with
| the optimization tool itself, which iam discussing here.

You should take the topic to the gcc mailing list.

Sharad
May 31 '06 #2
Abhishek wrote:
[g++ bug report redacted]

Bug reports for particular compilers are off-topic in this group. All we can
do is help you determine whether there is actually a bug. Since you did not
post the code, which may or may not exhibit undefined behavior, we cannot
help with that either.
Best

Kai-Uwe Bux

May 31 '06 #3
Abhishek wrote:
Recently i found that my C++ program was running fine with no
optimization and giving segmentation fault with error code 139 when
compiled with optimization level 2. I searched somewhat but never find
any systematic solution. In my recent attempt, i found the problem with
the optimization tool itself, which iam discussing here.

I found that the problem of segmentation fault was boiled down to a
statement of the form A = B, with no pointer or array usage, so forget
about the illegal memory write problems. When i removed this statement,
the problem disappers, so concluded that the segmentation fault problem
is with this statement. A careful study revealed that this statement
was redundant because A was never used in the program after this
statement. So i inserted one more statement after the above statement
which is "X = A", where X is a dummy variable and in that case the
problem again disappears. Inserting this new statement has made my
initial statement no more redundant.

I think the optimization tool had detected that A = B is a redundant
statement but failed to do its work. So its a clear bug in the
optimization tool itself.


Without any more code, it's hard to say if you're right. What type are A and
B? Could you provide a minimal, but complete program that shows the
behavior. Sometimes, a program crash happens in a place different from the
one that contains the error.

As others already mentioned: A g++ bug report would have to go to a
different place than here, but here, we could tell you if it's actually a
bug in the compiler or an error in your code. However, for that, you'd have
to show some code.

May 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2150
by: Alex Vinokur | last post by:
For instance, we need to measure performance of assignment 'ch1 = ch2' where ch1 and ch2 are of char type. We need to do that for different optimization levels of the same compiler. Here is some test program. Environment -----------
9
2406
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be'; $sentence = "$insert or not $insert. That is the question."; or
5
4424
by: AC Slater | last post by:
Whats the simplest way to change a single stored procedures query optimization level? In UDB8 that is. /F
2
5138
by: Eugene | last post by:
I am trying to set query optimization class in a simple SQL UDF like this: CREATE FUNCTION udftest ( in_item_id INT ) SPECIFIC udftest MODIFIES SQL DATA RETURNS TABLE( location_id INT, period_id INT ) BEGIN ATOMIC SET CURRENT QUERY OPTIMIZATION 1;
12
6207
by: WantedToBeDBA | last post by:
Hi all, db2 => create table emp(empno int not null primary key, \ db2 (cont.) => sex char(1) not null constraint s_check check \ db2 (cont.) => (sex in ('m','f')) \ db2 (cont.) => not enforced \ db2 (cont.) => enable query optimization) DB20000I The SQL command completed successfully. db2 => insert into emp values(1,'m')
24
8642
by: Kunal | last post by:
Hello, I need help in removing if ..else conditions inside for loops. I have used the following method but I am not sure whether it has actually helped. Below is an example to illustrate what I have used. Original code : c= 0 ; for (i=0; i<999; i++)
21
2586
by: mjbackues at yahoo | last post by:
Hello. I'm having a problem with the Visual Studio .net (2003) C++ speed optimization, and hope someone can suggest a workaround. My project includes many C++ files, most of which work fine with speed optimization turned on. At least one does not however, though it does work with size optimization turned on. I don't know specifically what the optimizer is doing wrong, just that the output is incorrect. And I know within about 10...
5
2394
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
2
4259
by: db2admin | last post by:
hi, I have query which runs great when optimization level is changed to 3 but does not run fine with default optimization level of 5. since this is a query in java code, i do not know how can i change optimization level of this one sql. also, developers are not comfortable with this. i am thinking of writing stored procedure in which i can execute sql with lower optimization level and return resultset to java code.
20
2363
by: Ravikiran | last post by:
Hi Friends, I wanted know about whatt is ment by zero optimization and sign optimization and its differences.... Thank you...
0
9603
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
10640
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
10376
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
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6881
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
5550
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
4332
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
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.