Bug#278081: gcc-3.3: REGRESSION: Doesn't follow precedence
Package: gcc-3.3
Version: 1:3.3.5-1
Severity: important
IMHO, this bug should be grave since it has a potential for
breaking a lot of software, at least anything that
depends on things like stack operations. That is
stack<int> A;
A.push(5);
A.push(2);
// do a subtraction of 5-2 and push resuls onto stack
A.push( -A.pop() + A.pop());
What it does, it actually A.pop() - A.pop() which is very wrong.
I can reproduce this problem on both gcc 3.3 (default) and gcc 3.4.
gcc 2.95 in woody compiles this code correctly, hence this is a regression.
You can rearrange -X+Y, as well as -X()+Y or -X+Y(), but you cannot do
this for -X()+Y() unless you can guarantee that X() doesn't depend on
Y() and vice-versa.
The following test case will also illustrate this problem. Hopefully
this regression doesn't translate to stable...
>>>>>>>>>>>>> TEST CASE >>>>>>>>>>>>>>
#include <stdio.h>
double A(){
static int div;
double r = 10.0/++div+div;
printf( "A() returns: %f iteration %d\n", r, div );
return r;
}
int main()
{
/* EXECUTES A()-A() INSTEAD OF -A()+A() */
printf( "-4.0 is %f\n", -A() + A());
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-1-k7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages gcc-3.3 depends on:
ii binutils 2.15-4 The GNU assembler, linker and bina
ii cpp-3.3 1:3.3.5-1 The GNU C preprocessor
ii gcc-3.3-base 1:3.3.5-1 The GNU Compiler Collection (base
ii libc6 2.3.2.ds1-18 GNU C Library: Shared libraries an
ii libgcc1 1:3.4.2-3 GCC support library
-- no debconf information
Reply to: