Bug 41114

Summary: Internal compiler error in fixup_var_refs_1, at function.c:1874
Product: [Retired] Red Hat Linux Reporter: Need Real Name <xiurong.zhu>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-12-15 14:51:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2001-05-17 16:36:08 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

Description of problem:
when compiling with KCC with gcc as backend compiler

How reproducible:
Always

Steps to Reproduce:
1.compile the code piece as follows

void check_complex_float (void)
{
    //
    // check operator for complex<float>
    //
    complex<float> x(1.0F, 1.0F);
    complex<float> y(0.0F, 0.0F);
    complex<float> z(3.0F, 3.0F);
    complex<float> t(-5.0F, -5.0F);  
 
    checkVal (x.real(), 1.0F);
    checkVal (x.imag(), 1.0F);
    checkVal (y.real(), 0.0F);
    checkVal (y.imag(), 0.0F);
    checkVal (z.real(), 3.0F);
    checkVal (z.imag(), 3.0F);
    checkVal (t.real(), -5.0F);
    checkVal (t.imag(), -5.0F);
 
    // 
    // Test 3.1: Perform some basic math
    //           operations
    //
    // Operation 1: Complex Number Addition of the type
    //              ComplexNumber += ComplexNumber
    //
    x += x;
    checkVal (x.real(), 2.0F);
    checkVal (x.imag(), 2.0F);
    y += y;
    checkVal (y.real(), 0.0F);
    checkVal (y.imag(), 0.0F);
    z += z;
    checkVal (z.real(), 6.0F);
    checkVal (z.imag(), 6.0F);
    t += t;
    checkVal (t.real(), -10.0F);
    checkVal (t.imag(), -10.0F);
 
    //
    // Operation 2: Complex Number Multiplication of the type
    //              ComplexNumber *= ComplexNumber
    //
    x *= x;
    checkVal (x.real(),  0.0F);
    checkVal (x.imag(),  8.0F);
    y *= y;
    checkVal (y.real(),  0.0F);
    checkVal (y.imag(),  0.0F);
    
    //
    // Operation 3: Complex Number Division of the type
    //              ComplexNumber /= ComplexNumber
    //
    x /= x;
    checkVal (x.real(),  1.0F);
    checkVal (x.imag(),  0.0F);
    z /= z;
    checkVal (z.real(), 1.0F);
    checkVal (z.imag(), 0.0F);
 
    //
    // Operation 4: Complex Number Subtraction of the type
    //              ComplexNumber -= ComplexNumber
    //
    x -= x; 
    checkVal (x.real(), 0.0F);
    checkVal (x.imag(), 0.0F);
    y -= y; 
    checkVal (y.real(), 0.0F);
    checkVal (y.imag(), 0.0F);
}
with KCC
2.the error message shows during compilation

3.the error is pointing to the end of the function above
	

Actual Results:  compilation failed

Expected Results:  compilation successful

Additional info:

Comment 1 Jakub Jelinek 2001-06-06 10:49:53 UTC
You need to include self-contained testcase (this is not one) and write
what exact command line you used (KCC is some Japanesse package, did you mean
kgcc? What do you mean by using gcc as backend?).
I've added
#include <complex>
void checkVal(float,float);
at the start of the file and it compiled just fine with various optimization options,
with gcc, g++, egcs++, kgcc.

Comment 2 Need Real Name 2001-06-07 16:27:57 UTC
Hi:
KCC is our own C++ compiler (see www.kai.com) on most Unix systems. We use gcc 
as backend compiler on all linux rh systems. Our KCC's frontend optimizes c and 
c++ code, it then generates and passes intermediate c code to gcc for final 
compilation. 

The following is reduced code we passed to KCC:

#include <complex.h>
void check_complex_float (void)
{
    //
    // check operator for complex<float>
    //
    complex<float> x((float)0.0, (float)1.0);
    //
    // Operation 1: Complex Number Multiplication of the type
    //              ComplexNumber *= ComplexNumber
    //
    x *= x;

    //
    // Operation 2: Complex Number Division of the type
    //              ComplexNumber /= ComplexNumber
    //
   x /= x;
}
int main ()
{
    return 1;
}

where we defined templated complex class in our own library. The above code 
will stop compiling when we turn on inlining specification to certain degree 
(KCC's own optimization option). 

So, what I did next is to let our KCC frontend to run above file with the bad 
inlining option, which generated the file that is supposed to be passed to gcc.
The following is the modified version the file in readable c code:

struct my_complex {
        float re;
        float im;
};
extern void check_complex_float(void);
extern int main(void);
static __inline__ struct my_complex *divide(struct my_complex *const, const 
struct my_complex *);
void check_complex_float(void)
{
        float f1;
        struct my_complex com1;
        float f2;
        float f3;
        (com1.re) = (1.F); (com1.im) = (0.F);
        f2 = (((com1.re)) * ((com1.re))); f3 = (f2 - (((com1.im)) * 
((com1.im))));
        f1 = (((com1.im)) * ((com1.re))); (com1.im) = (f1 + (((com1.re)) * 
((com1.im))));
        (com1.re) = f3;
        divide((&com1), ((const struct my_complex *)(&com1)));
        return;
}
int main(void)
{
check_complex_float();
return 1;
}
static __inline__ struct my_complex *divide( struct my_complex *const this,  
const struct my_complex *com) {
        float f1;
        double d1;
        double d2;
        float f2;
        float f_re;
        float f_im;
        float f_d;
        struct my_complex com1;
        float f_c;
        double d_y;

        f_d = ((this->im)); f_c = ((this->re));
        f1 = ((com->im));
        f2 = ((com->re));
        d_y = ((double)f1);
        d2 = ((double)f2);

        d1 = ((1.) / ((d2 * d2) + (d_y * d_y)));
        f_re = ((float)(((((double)f_c) * d2) + (((double)f_d) * d_y)) * d1));
        f_im = ((float)(((((double)f_d) * d2) - (((double)f_c) * d_y)) * d1));
        (com1.re) = f_re; (com1.im) = f_im;
        (this->re) = ((com1.re)); (this->im) = ((com1.im));
        return this;
}

Compiling it with gcc having the option of
       -O -ansi -c -v ( or just -ansi -c -v) 
will result in the following error message from gcc:
   

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (RedHat Linux 7.1 2.96-81)
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cpp0 -lang-c -std=c89 -v -D__GNUC__=2 -
D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -D__unix__ -D__linux
__ -D__unix -D__linux -Asystem(posix) -D__OPTIMIZE__ -Acpu(i386) -Amachine
(i386) -D__i386 -D__i386__ -D__tune_i386__ gcc_error_1.c /tmp/cczsj0gQ.i
GNU CPP version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) (cpplib) (i386 
Linux/ELF)
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cc1 /tmp/cczsj0gQ.i -quiet -dumpbase 
gcc_error_1.c -ansi -O -ansi -version -o /tmp/ccuxjlYv.s
GNU C version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) (i386-redhat-linux) 
compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.1 2.96-81).
gcc_error_1.c: In function `check_complex_float':
gcc_error_1.c:20: Internal compiler error in fixup_var_refs_1, at 
function.c:1874
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

Please let me know as soon as possible your comments. Thanks