optimization/2918: long long assignment lost
pauli@lineo.com
pauli@lineo.com
Wed May 23 20:06:00 GMT 2001
>Number: 2918
>Category: optimization
>Synopsis: long long assignment lost
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed May 23 20:06:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Paul Dale
>Release: gcc version 2.95.3 20010315 (release)
>Organization:
>Environment:
Linux skaro 2.2.16-22 #1 Tue Aug 22 16:49:06 EDT 2000 i686 unknown
x86 platform cross compiling to coldfire
>Description:
When the attached C file is built using:
$ m68k-elf-gcc -m5200 -O1 -save-temps pauli.c -c
or
$ m68k-elf-gcc -m5200 -O2 -save-temps pauli.c -c
incorrect code is generated. Specifically, the second assignment
in the function body is discarded. Compiling with -O0
generates correct code.
>How-To-Repeat:
struct c {
unsigned long long a, b;
};
void x(unsigned long *p, struct c *d)
{
d->b = d->a;
d->a = *p;
}
>Fix:
Declaring a volatile unsigned long temporary variable and
storing *p into here and then this variable in d->a
circumvents the problem.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list