-fdefer-pop causes core-dump in egcs-1.1.2 g++

Chris Rankin rankinc@zip.com.au
Fri Jul 16 06:54:00 GMT 1999


Hi,
The following program core-dumps if compiled with -fdefer-pop
However, it works fine even at -O3 if you also use -fno-defer-pop.

Cheers,
Chris.

-----------------------------------------------------------------------------
#include <map>
using namespace std;

typedef map<int, int>  DataCollect;

int
main()
{
  DataCollect  collect;
  int i;

  try
  {
    for (i=0; i < 20; ++i)
    {
      if ( !collect.insert( make_pair(i, i*100) ).second )
      {
        cerr << "Failed to insert: " << i << endl;
      }
    } /* for */

    DataCollect::const_iterator  iter;
    for (iter = collect.begin(); iter != collect.end(); ++iter)
    {
      cout << "first: " << iter->first
           << ", second: " << iter->second
           << endl;

      if ( iter->first == 11 ) throw 1;
    } /* for */

    collect.clear();
  }
  catch(...)
  {
    collect.clear();
  }

  cout << "Terminating..." << endl;
  return 0;
}

Makefile --------------------------------------------------------------------
CXX=g++
CXXFLAGS=-O3 -fomit-frame-pointer -felide-constructors \
         -fnonnull-objects -fstrict-aliasing \
         -Wall -Wsign-compare -Wwrite-strings -Wmissing-declarations \
         -Wmissing-prototypes -Wstrict-prototypes

ifdef BUGFIX
CXXFLAGS += -fno-defer-pop
endif

##############################################################################
## Rules
.PHONY: clean

testmap: testmap.cpp
	${CXX} ${CXXFLAGS} -o $@ $^

clean:
	rm -f testmap *.o core

-----------------------------------------------------------------------------
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)


More information about the Gcc-bugs mailing list