This is the mail archive of the gcc-prs@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]

c++/144: Re: Exception handling bug (2): gcc-2.95.2 (unfixed from gcc-2.95.1)



>Number:         144
>Category:       c++
>Synopsis:       Exception handling bug (2): gcc-2.95.2 (unfixed from gcc-2.95.1)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          analyzed
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 26 12:46:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Chris Rankin <rankinc@zip.com.au>
>Release:        2.95.2
>Organization:
>Environment:
>Description:
 Original-Message-ID: <3816D157.ACF23314@zipworld.com.au>
 Date: Wed, 27 Oct 1999 20:17:59 +1000

 The following code core-dumps when compiled with gcc-2.95.2,
 i586-pc-linux-gnu using binutils 2.9.5. The problem seems to be
 triggered when the -fomit-frame-pointer option is active.

 Cheers,
 Chris.
>How-To-Repeat:
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# 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 2000-03-26 22:41 CEST by <martin@mira>.
# Source directory was `/home/martin/tmp'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   1443 -rw-rw-r-- testframe.cpp
#    583 -rw-r--r-- Makefile
#
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
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
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 1231235999 $$.touch
#
if mkdir _sh11914; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= testframe.cpp ==============
if test -f 'testframe.cpp' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'testframe.cpp' '(file already exists)'
else
  $echo 'x -' extracting 'testframe.cpp' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'testframe.cpp' &&
#include <string>
#include <iostream>
using namespace std;
X
X
/******************************************************
X * class Exception
X */
class Exception {
private:
X  string m_msg;
public:
X  Exception(const string &msg) : m_msg(msg) {}
X  const string& get_msg() const { return m_msg; }
};
X
void throw_Exception(const string &msg)  __attribute__((noreturn));
X
X
void
throw_Exception(const string &msg)
{
X  throw Exception(msg);
}
X
/***************************************************
X * class Thing
X */
class Thing
{
public:
X  Thing();
X  void open();
X
X  static bool is_error(int)  __attribute__((const));
X  static void check_code(int);
};
X
X
Thing::Thing() {}
X
X
inline bool
Thing::is_error(int code)
{
X  return (code >= 400) && (code <= 599);
}
X
X
void
Thing::check_code(int code)
{
X  if ( is_error(code) )
X  {
X    throw_Exception("crash!");
X  }
}
X
X
void
Thing::open()
{
X  check_code(530);
}
X
X
/************************************************************
X * class AppObj
X */
class AppObj
{
private:
X  Thing m_thing;
X
public:
X  AppObj();
X  void open();
};
X
X
AppObj::AppObj()
X  : m_thing()
{}
X
X
void
AppObj::open()
{
X  m_thing.open();
}
X
X
/************************************************************
X * main
X */
int
main()
{
X  try
X  {
X    AppObj  app;
X    app.open();
X  }
X  catch(const Exception &e)
X  {
X    cout << "Caught application exception" << endl;
X  }
X  catch(...)
X  {
X    cout << "Caught unknown exception" << endl;
X
X  }
X
X  return 0;
}
SHAR_EOF
  $shar_touch -am 03262238100 'testframe.cpp' &&
  chmod 0664 'testframe.cpp' ||
  $echo 'restore of' 'testframe.cpp' '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 'testframe.cpp:' 'MD5 check failed'
96ae30207f1badafc604f9c55f4c2033  testframe.cpp
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'testframe.cpp'`"
    test 1443 -eq "$shar_count" ||
    $echo 'testframe.cpp:' 'original size' '1443,' 'current size' "$shar_count!"
  fi
fi
# ============= Makefile ==============
if test -f 'Makefile' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'Makefile' '(file already exists)'
else
  $echo 'x -' extracting 'Makefile' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
CXX=/usr/local/newabi/bin/g++
CXXFLAGS=-O3 -felide-constructors \
X         -Wall -Wsign-compare -Wwrite-strings -Wmissing-declarations \
X         -Wmissing-prototypes -Wstrict-prototypes -W -Wpointer-arith
X
ifdef BUGFIX
CXXFLAGS += -fno-omit-frame-pointer
else
CXXFLAGS += -fomit-frame-pointer
endif
X
STRIP=strip
SFLAGS=-p -R .note -R .comment
X
##############################################################################
## Rules
X.PHONY: all clean
all: testframe
X
testframe: testframe.cpp
X	${CXX} ${CXXFLAGS} -o $@ $^
X	${STRIP} ${SFLAGS} $@
X
clean:
X	rm -f testframe *.o core *~
X
X
SHAR_EOF
  $shar_touch -am 03262239100 'Makefile' &&
  chmod 0644 'Makefile' ||
  $echo 'restore of' 'Makefile' '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 'Makefile:' 'MD5 check failed'
d8f6d8e2280a1083db5d3fbbad702f78  Makefile
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Makefile'`"
    test 583 -eq "$shar_count" ||
    $echo 'Makefile:' 'original size' '583,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh11914
exit 0
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:

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