Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 163058 - Invalid executable. Mangled struct arguments to function
Summary: Invalid executable. Mangled struct arguments to function
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc4
Version: 4
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-07-12 17:37 UTC by Brian McGurk
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version: 4.0.1-3.fc4
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-07-21 21:00:14 UTC


Attachments (Terms of Use)

Description Brian McGurk 2005-07-12 17:37:17 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050524 Fedora/1.0.4-4 Firefox/1.0.4

Description of problem:
The output from the compiler is broken with '-O2' optimisation turned on. After two levels of function calls, the arguments to the final function are the same when they should be different.

Here is a simple program that reproduces the problem:

struct number {
        int value;
        int only_here_to_cause_a_bug_1;
        int only_here_to_cause_a_bug_2;
};

int different(struct number a, struct number b);
int still_different(struct number a, struct number b);

int main(int argc, char **argv)
{
        struct number three, seven;

        three.value = 3;
        seven.value = 7;

        return ! different(three, seven);
}

int different(struct number a, struct number b)
{
        return still_different(b, a);
}

int still_different(struct number a, struct number b) {
        return (a.value != b.value);
}

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

How reproducible:
Always

Steps to Reproduce:
1.Save the above program in a file try.c
2.Run '/usr/bin/gcc -O2 try.c'
3.Run './a.out'
  

Actual Results:  The program exits with an error status

Expected Results:  It should exit without an error status.

Additional info:

Removing the unused fields from the structure removes the problem.

Reducing the optimisation removes the problem.

Reversing the order of the arguments in the call to the function "still_different"   
 removes the problem.

Comment 2 Jakub Jelinek 2005-07-21 21:00:14 UTC
Should be fixed in gcc-4.0.1-4 (rawhide) and gcc-4.0.1-3.fc4 (FC4 testing
update).


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