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]
Other format: [Raw text]

[Bug c++/15143] New: using some template with 0 leads to segmentation fault in g++


I am not shure, whether this program/templates are correct -
but anyway: the compiler should not seg.fault!

This is what happens:

gasi@luanda:tmp$ /app/lang/gcc/3.4/bin/g++ -v bug.cc 
Reading specs from /app/lang/gcc/3.4/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --prefix=/app/lang/gcc/3.4
Thread model: posix
gcc version 3.4.0
 /app/lang/gcc/3.4/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -quiet -v
-D_GNU_SOURCE bug.cc -quiet -dumpbase bug.cc -mtune=pentiumpro -auxbase bug
-version -o /tmp/ccRQKWjz.s
ignoring nonexistent directory
"/app/lang/gcc/3.4/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /app/lang/gcc/3.4/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
 /app/lang/gcc/3.4/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
 /app/lang/gcc/3.4/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
 /usr/local/include
 /app/lang/gcc/3.4/include
 /app/lang/gcc/3.4/lib/gcc/i686-pc-linux-gnu/3.4.0/include
 /usr/include
End of search list.
GNU C++ version 3.4.0 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128986
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

AND THIS IS THE SOURCE:
----------------------------------------------------------
template<class T> class ListEntry;

template<class T>
class List {
public:
	List() { entry = 0; }
	//!! without the following line, there is a syntax error (?):
	List( T info, List next=0 ) {}
	~List() {}
	void ins( T info ) { entry = new ListEntry<T>(info); }
	//!! Using the following line allows compilation
	//void ins( T info ) { entry = new ListEntry<T>(info,*this); }
	ListEntry<T> *entry;
};

template<class T>
class ListEntry {
public:
	ListEntry( T _info, List<T> _next=0 ):info(_info),next(_next) {}
	~ListEntry() {}
	T	info;
	List<T>	next;
};

int main() {
	List<int> l;
	l.ins(123);
	return 0;
}
----------------------------------------------------------

-- 
           Summary: using some template with 0 leads to segmentation fault
                    in g++
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gasi3 at web dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15143


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