Bug 90356 - wrong code generated for attached source file
Summary: wrong code generated for attached source file
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
(Show other bugs)
Version: 9
Hardware: i386 Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-05-07 13:23 UTC by Jeff Epler
Modified: 2007-04-18 16:53 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-03 23:11:02 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Jeff Epler 2003-05-07 13:23:00 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;) Gecko/20021203

Description of problem:
A simple function is miscompiled under the following combination of flags: -O
-fPIC -pg

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

How reproducible:
Always

Steps to Reproduce:
1. Create two source files

2. Compile with proper cflags
$ gcc -O2 -fPIC -pg -c bug.c
$ gcc -pg -c bug-main.c
$ gcc -pg bug.o bug-main.o

3. Execute resulting binary
$ ./a.out
Segmentation fault


Actual Results:  Segmentation fault

Expected Results:  Program exits with result code 0

Additional info:
/* bug.c */
/* compile with -pg -fPIC -O2 -> wrong code generated by redhat 9's gcc */
typedef struct { void *(*f)(void *, int); } T;
void *g(T *t) { return t->f(t, 0); }

To actually show the problem, you also need this:
/* bug-main.c */
/* compile with -pg (at least) and use with bug.c */
typedef struct { void *(*f)(void *, int); } T;
void *ff(void* a, int b) { return 0; }
int main(void) { T x = {ff}; g(&x); return 0; }

Comment 1 Jeff Epler 2003-05-07 13:23:37 UTC
This is a regression compared to gcc 3.2.2 as released on gcc.gnu.org

Comment 2 Jeff Epler 2003-12-22 03:27:42 UTC
The attached testcase seems to compile properly on fedora core with
gcc-3.3.2-1

Comment 3 Richard Henderson 2004-10-03 23:11:02 UTC
Fixed in gcc-3.2.3-20.


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