This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc bug and BSDI build error



Hello.
 I have a question about the gcc compiler. I have noticed a reproducible behaviour that would seem to be a bug, and I'd like your opinion on it.
This is using gcc 2.7.2.1 on i386-pc-bsdi4.0.1.

 I can not determine if the behaviour exists in gcc 2.95.2 because it will not compile. I have tried to compile it on 3 different i386-pc-bsdi4.0.1 machines with the same result.

COMPILE PROBLEM:

GCC version: 2.95.2
system type: i386-pc-bsdi4.0.1

commands used to make: 
 mkdir builddir
 cd builddir
 ../gcc-2.95.2/configure --with-stabs --enable-languages=c++
 make bootstrap

The make craps out at this point:

mv -f cplib2.new cplib2.txt
rm -f tmplibgcc2.a
for name in _muldi3 _divdi3 _moddi3 _udivdi3 _umoddi3 _negdi2  _lshrdi3
_ashldi3 _ashrdi3 _ffsdi2  _udiv_w_sdiv _udivmoddi4 _cmpdi2 _ucmpdi2
_floatdidf _floatdisf  _fixunsdfsi _fixunssfsi _fixunsdfdi _fixdfdi
_fixunssfdi _fixsfdi  _fixxfdi _fixunsxfdi _floatdixf _fixunsxfsi 
_fixtfdi _fixunstfdi _floatditf  __gcc_bcmp _varargs __dummy _eprintf 
_bb _shtab _clear_cache _trampoline __main _exit  _ctors _pure;  do 
echo ${name};  ./xgcc -B/usr/local/i386-pc-bsdi4.0.1/bin/ -B./
-I/usr/local/i386-pc-bsdi4.0.1/include -O2   -DIN_GCC    -g
-I./include   -g1  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I.
-I../../gcc-2.95.2/gcc -I../../gcc-2.95.2/gcc/config
-I../../gcc-2.95.2/gcc/../include -c -DL${name}  
../../gcc-2.95.2/gcc/libgcc2.c -o ${name}.o;  if [ $? -eq 0 ] ; then
true; else exit 1; fi;  `  if [ -f
/usr/local/source/builddir/gcc/../binutils/ar ] ; then  echo
/usr/local/source/builddir/gcc/../binutils/ar ;  else  if [
"i386-pc-bsdi4.0.1" = "i386-pc-bsdi4.0.1" ] ; then  echo ar;  else 
t='s,x,x,'; echo ar | sed -e $t ;  fi;  fi` rc tmplibgcc2.a ${name}.o; 
rm -f ${name}.o;  done
_muldi3
_divdi3
_moddi3
_udivdi3
_umoddi3
_negdi2
_lshrdi3
_ashldi3
_ashrdi3
_ffsdi2
_udiv_w_sdiv
_udivmoddi4
_cmpdi2
_ucmpdi2
_floatdidf
/var/tmp/ccslQAtL.s: Assembler messages:
/var/tmp/ccslQAtL.s:121: Error: Alignment not a power of 2
*** Error code 1

Can you point out my mistake or tell me what is wrong? I can supply you with more of the make output.

POSSIBLE BUG:

 The behaviour I noticed happens when I try to use a static variable inside a static member function. When calling the static function and all the calls are in the same .C file, everything is fine. But when the static function is called from a second .C file, the static variable has a different address. This is shown below:


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

template <class TYPE>
class Singleton {
protected:
  Singleton() {}
  ~Singleton() {}

public:
  static TYPE *Get();
};

template <class TYPE>
TYPE *Singleton<TYPE>::Get()
{
  static TYPE *var = NULL;

  if (!var) var = new TYPE();
  printf("made %p = %p\n",&var,var);
  return var;
}

class Config : public Singleton<Config> {
protected:
  friend Singleton<Config>;
   Config() {}
  ~Config() {}
};

/********/
void part3()
{
  Config *c;

  c = Config::Get();
}

/********/
int
main()
{
  Config *c;

  c = Config::Get();
  part3();
} 

When the code is all in one file, the sample output is:
made 0x8049554 = 0x804d130
made 0x8049554 = 0x804d130

When the code is in three different files, divided at the comments (with appropriate headers and prototypes added), the sample output is:
made 0x80495d8 = 0x804d130
made 0x80495dc = 0x804d170

Isn't this wrong? 

Thanks for your attention!
-Jeremy
-----------------------------------------------
Free & Easy!  Love, Peace, Email   http://JMAIL.CO.JP

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]