This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 163058 - Invalid executable. Mangled struct arguments to function
Invalid executable. Mangled struct arguments to function
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gcc4 (Show other bugs)
4
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-07-12 13:37 EDT by Brian McGurk
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: 4.0.1-3.fc4
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-07-21 17:00:14 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Brian McGurk 2005-07-12 13:37:17 EDT
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 17:00:14 EDT
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.