Bug 54037 - Using -O flag changes behaviour of program
Using -O flag changes behaviour of program
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2001-09-26 06:11 EDT by Pedro Miguel Marques Morais
Modified: 2007-04-18 12:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-01 20:19:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Source code (754 bytes, text/plain)
2001-09-26 06:16 EDT, Pedro Miguel Marques Morais
no flags Details
Makefile (623 bytes, text/plain)
2001-09-26 06:17 EDT, Pedro Miguel Marques Morais
no flags Details

  None (edit)
Description Pedro Miguel Marques Morais 2001-09-26 06:11:57 EDT
Description of Problem:

In the attached file, compiling the program with and without -O changes the
warnings given. Also, the compiler performs an invalid optimization, that
code without -O runs fine, code with -O core dumps

Version-Release number of selected component (if applicable):

It also happens using gcc3.

How Reproducible:


Steps to Reproduce:
1. Get the two attached files, test.c and Makefile
2. make

Actual Results:

Two warnings, Two core dumps

Expected Results:

No warnings or core dumps OR 4 warnings and 4 core dumps:
consistent behaviour between -O and no -O
Comment 1 Pedro Miguel Marques Morais 2001-09-26 06:16:40 EDT
Created attachment 32638 [details]
Source code
Comment 2 Pedro Miguel Marques Morais 2001-09-26 06:17:47 EDT
Created attachment 32639 [details]
Comment 3 Alan Cox 2002-12-15 12:49:43 EST
still true in gcc 3.2
Comment 4 Richard Henderson 2004-10-01 20:19:36 EDT
This is invalid code.  Only const references may be bound to
temporaries.  You may find some commentary useful at


Note You need to log in before you can comment on or make changes to this bug.