[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

g++



>Submitter-Id:	net
>Originator:	Ove Kaaven <ovek@arcticnet.no>
>Organization:	The Debian project
>Confidential:	no
>Synopsis:	g++
>Severity:	serious
>Priority:	low
>Category:	c++
>Class:		wrong-code
>Release:	3.0.1 (CVS 20010801) (Debian GNU/Linux)
>Environment:
System: Debian GNU/Linux (testing/unstable)
Architecture: sparc
	
host: sparc-linux
build: sparc-linux
target: sparc-linux
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc sparc-linux
>Description:
[ Reported to the Debian BTS as report #88694.
  Please CC 88694-quiet@bugs.debian.org on replies.
  Log of report can be found at http://bugs.debian.org/88694 ]
 	

The compiler optimizes out the variable, which is OK without -g, but
with -g, the stabs debugging info explicitly references the
optimized-out variable, causing an undefined reference, and the
application (e.g. flightgear) will fail to link (seen on sparc-linux,
not i386-linux).

typedef double SCALAR;

typedef SCALAR VECTOR_3[3];

class LaRCsimIC {
public:
  SCALAR xlo, xhi,xmin,xmax;

  typedef SCALAR (LaRCsimIC::*fp)(SCALAR x);
  fp sfunc;

  bool solve( SCALAR *y,SCALAR x);
};

bool LaRCsimIC::solve( SCALAR *y,SCALAR x) {
  float x1,x2,x3,f1,f2,f3,d,d0;
  float eps=1E-5;
  float const relax =0.9;
  int i;
  bool success=false;

  d=1;
  
    x1=xlo;x3=xhi;
    f1=(this->*sfunc)(x1)-x;
    f3=(this->*sfunc)(x3)-x;
    d0=fabs(x3-x1);
  
    //iterations
    i=0;
    while ((fabs(d) > eps) && (i < 100)) {
      d=(x3-x1)/d0;
      x2=x1-d*d0*f1/(f3-f1);
      
      f2=(this->*sfunc)(x2)-x;

      if(fabs(f2) <= 0.001) {
        x1=x3=x2;
      } else if(f1*f2 <= 0.0) {
        x3=x2;
        f3=f2;
        f1=relax*f1;
      } else if(f2*f3 <= 0) {
        x1=x2;
        f1=f2;   
        f3=relax*f3;
      }
      i++;
    }//end while
    if(i < 100) {
      success=true;
      *y=x2;  
    }

  return success;
}

$ g++-3.0 -O2 -g -c bug.cc ; nm bug.o 
0000000000000000 a *ABS*
                 U .LLC0
00000000000002c8 t Letext
0000000000000000 T _ZN9LaRCsimIC5solveEPdd
0000000000000000 ? __FRAME_BEGIN__
                 U __gxx_personality_v0
                 U fabs

$ g++-3.0 -O2 -c bug.cc ; nm bug.o
0000000000000000 a *ABS*
0000000000000000 T _ZN9LaRCsimIC5solveEPdd
0000000000000000 ? __FRAME_BEGIN__
                 U __gxx_personality_v0
                 U fabs

>How-To-Repeat:
	
>Fix:
	



Reply to: