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]

template bug on HPUX 11 in GCC 3.0 branch



  I was testing the gcc 3.0 branch the other day on HPUX 11.00, and found that
an old bug in GCC 2.95.2 and 2.95.3 is still there. (it's also in the GNUPro 
branch as well) I'm trying this on hppa2.0w-hp-hpux11.00. (a PA-RISC based
J5600) This test case reproduces the problem. Compile main.c and sub.c, and
when executed, it should print:

push count 9
push count 10

  On HPUX 11.00, it prints 9 twice. What seems to be happening is that the 
static variable instantiated in stack::push() is getting multiple copies,
one for each object file. It should only get one copy. This works on Solaris
and Linux. It'd be nice if this could get fixed before the real release...

	- rob -

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2001-06-10 16:09 MST by <rob@peggyo.welcomehome.org>.
# Source directory was `/tmp'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#     87 -rw-rw-r-- main.c
#     65 -rw-rw-r-- sub.c
#    257 -rw-rw-r-- stack.h
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh02614; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= main.c ==============
if test -f 'main.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'main.c' '(file already exists)'
else
  $echo 'x -' extracting 'main.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'main.c' &&
#include <stack.h>
void sub();
int main() {
X   stack<int> s;
X   s.push(5);
X   sub();
}
SHAR_EOF
  (set 20 01 03 28 17 05 13 'main.c'; eval "$shar_touch") &&
  chmod 0664 'main.c' ||
  $echo 'restore of' 'main.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'main.c:' 'MD5 check failed'
aaa035234c3789c84617600a284cea14  main.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'main.c'`"
    test 87 -eq "$shar_count" ||
    $echo 'main.c:' 'original size' '87,' 'current size' "$shar_count!"
  fi
fi
# ============= sub.c ==============
if test -f 'sub.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'sub.c' '(file already exists)'
else
  $echo 'x -' extracting 'sub.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'sub.c' &&
#include <stack.h>
void sub() {
X   stack<int> s;
X   s.push(5);
}
SHAR_EOF
  (set 20 01 03 28 17 04 03 'sub.c'; eval "$shar_touch") &&
  chmod 0664 'sub.c' ||
  $echo 'restore of' 'sub.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'sub.c:' 'MD5 check failed'
579199957d3f6309fe57e277838c488a  sub.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'sub.c'`"
    test 65 -eq "$shar_count" ||
    $echo 'sub.c:' 'original size' '65,' 'current size' "$shar_count!"
  fi
fi
# ============= stack.h ==============
if test -f 'stack.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'stack.h' '(file already exists)'
else
  $echo 'x -' extracting 'stack.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'stack.h' &&
#ifndef STACK_H
#define STACK_H
#include <stdio.h>
template <class T>
class stack {
public:
X   void push(T);
X   T SS;
};
template <class T>
void stack<T>::push(T t) {
X   static int count=9;
X   printf("push count %d\n", count);
X   SS = t + count++;
}
#endif
SHAR_EOF
  (set 20 01 03 28 17 06 33 'stack.h'; eval "$shar_touch") &&
  chmod 0664 'stack.h' ||
  $echo 'restore of' 'stack.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'stack.h:' 'MD5 check failed'
a46f76551f6c62de45d54664fd6bcb62  stack.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'stack.h'`"
    test 257 -eq "$shar_count" ||
    $echo 'stack.h:' 'original size' '257,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh02614
exit 0


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