public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: galen_sampson@yahoo.com To: gcc-gnats@gcc.gnu.org Subject: c++/8561: Segfault when template class is not defined. Date: Tue, 19 Nov 2002 18:39:00 -0000 [thread overview] Message-ID: <20021113181007.20029.qmail@sources.redhat.com> (raw) >Number: 8561 >Category: c++ >Synopsis: Segfault when template class is not defined. >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: ice-on-illegal-code >Submitter-Id: net >Arrival-Date: Wed Nov 13 10:16:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Galen Sampson >Release: gcc version 3.2.1 [FreeBSD] 20021009 (prerelease) >Organization: >Environment: ~/test> g++ -v Using built-in specs. Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 3.2.1 [FreeBSD] 20021009 (prerelease) >Description: Attempting to compile the attached two files yeilds the ice: ~/test> g++ -Wall -c btree.cpp btree.cpp:27: internal error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. The commented line in btree.h (line 12) can be uncommented and the compiler will complete sucessfully. >How-To-Repeat: g++ -Wall -c btree.cpp >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="btree.ii" Content-Disposition: inline; filename="btree.ii" # 1 "btree.cpp" # 1 "<built-in>" # 1 "<command line>" # 1 "btree.cpp" # 1 "btree.h" 1 # 1 "/usr/include/g++/cstdlib" 1 3 # 48 "/usr/include/g++/cstdlib" 3 # 1 "/usr/include/g++/bits/c++config.h" 1 3 # 36 "/usr/include/g++/bits/c++config.h" 3 # 1 "/usr/include/g++/bits/os_defines.h" 1 3 # 37 "/usr/include/g++/bits/c++config.h" 2 3 # 50 "/usr/include/g++/cstdlib" 2 3 # 1 "/usr/include/g++/cstddef" 1 3 # 47 "/usr/include/g++/cstddef" 3 # 1 "/usr/include/stddef.h" 1 3 # 41 "/usr/include/stddef.h" 3 # 1 "/usr/include/sys/cdefs.h" 1 3 # 42 "/usr/include/stddef.h" 2 3 # 1 "/usr/include/sys/_types.h" 1 3 # 33 "/usr/include/sys/_types.h" 3 # 1 "/usr/include/machine/_types.h" 1 3 # 45 "/usr/include/machine/_types.h" 3 typedef signed char __int8_t; typedef unsigned char __uint8_t; typedef short __int16_t; typedef unsigned short __uint16_t; typedef int __int32_t; typedef unsigned int __uint32_t; typedef int __attribute__((__mode__(__DI__))) __int64_t; typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t; # 70 "/usr/include/machine/_types.h" 3 typedef unsigned long __clock_t; typedef __int32_t __critical_t; typedef __int32_t __intfptr_t; typedef __int64_t __intmax_t; typedef __int32_t __intptr_t; typedef __int32_t __int_fast8_t; typedef __int32_t __int_fast16_t; typedef __int32_t __int_fast32_t; typedef __int64_t __int_fast64_t; typedef __int8_t __int_least8_t; typedef __int16_t __int_least16_t; typedef __int32_t __int_least32_t; typedef __int64_t __int_least64_t; typedef __int32_t __ptrdiff_t; typedef __int32_t __register_t; typedef __int32_t __segsz_t; typedef __uint32_t __size_t; typedef __int32_t __ssize_t; typedef __int32_t __time_t; typedef __uint32_t __uintfptr_t; typedef __uint64_t __uintmax_t; typedef __uint32_t __uintptr_t; typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; typedef __uint32_t __uint_fast32_t; typedef __uint64_t __uint_fast64_t; typedef __uint8_t __uint_least8_t; typedef __uint16_t __uint_least16_t; typedef __uint32_t __uint_least32_t; typedef __uint64_t __uint_least64_t; typedef __uint32_t __u_register_t; typedef __uint32_t __vm_offset_t; typedef __int64_t __vm_ooffset_t; typedef __uint64_t __vm_pindex_t; typedef __uint32_t __vm_size_t; typedef __builtin_va_list __va_list; typedef __va_list __gnuc_va_list; # 34 "/usr/include/sys/_types.h" 2 3 typedef __int32_t __clockid_t; typedef __uint32_t __fflags_t; typedef __uint64_t __fsblkcnt_t; typedef __uint64_t __fsfilcnt_t; typedef __uint32_t __gid_t; typedef __int64_t __id_t; typedef long __key_t; typedef __uint16_t __mode_t; typedef int __nl_item; typedef __int64_t __off_t; typedef __int32_t __pid_t; typedef __int64_t __rlim_t; typedef __uint8_t __sa_family_t; typedef __uint32_t __socklen_t; typedef __int32_t __timer_t; typedef __uint32_t __uid_t; # 73 "/usr/include/sys/_types.h" 3 typedef int __ct_rune_t; typedef __ct_rune_t __rune_t; typedef __ct_rune_t __wchar_t; typedef __ct_rune_t __wint_t; typedef union { char __mbstate8[128]; __int64_t _mbstateL; } __mbstate_t; # 43 "/usr/include/stddef.h" 2 3 typedef __ptrdiff_t ptrdiff_t; typedef __rune_t rune_t; typedef __size_t size_t; # 49 "/usr/include/g++/cstddef" 2 3 namespace std { using ::ptrdiff_t; using ::size_t; } # 51 "/usr/include/g++/cstdlib" 2 3 # 1 "/usr/include/stdlib.h" 1 3 # 62 "/usr/include/stdlib.h" 3 typedef struct { int quot; int rem; } div_t; typedef struct { long quot; long rem; } ldiv_t; # 81 "/usr/include/stdlib.h" 3 extern int __mb_cur_max; extern "C" { void abort(void) __attribute__((__noreturn__)); int abs(int) __attribute__((__const__)); int atexit(void (*)(void)); double atof(const char *); int atoi(const char *); long atol(const char *); void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); void *calloc(size_t, size_t); div_t div(int, int) __attribute__((__const__)); void exit(int) __attribute__((__noreturn__)); void free(void *); char *getenv(const char *); long labs(long) __attribute__((__const__)); ldiv_t ldiv(long, long) __attribute__((__const__)); void *malloc(size_t); int mblen(const char *, size_t); size_t mbstowcs(wchar_t * , const char * , size_t); int mbtowc(wchar_t * , const char * , size_t); void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); int rand(void); void *realloc(void *, size_t); void srand(unsigned); double strtod(const char * , char ** ); long strtol(const char * , char ** , int); unsigned long strtoul(const char * , char ** , int); int system(const char *); int wctomb(char *, wchar_t); size_t wcstombs(char * , const wchar_t * , size_t); # 133 "/usr/include/stdlib.h" 3 typedef struct { long long quot; long long rem; } lldiv_t; long long atoll(const char *); long long llabs(long long) __attribute__((__const__)); lldiv_t lldiv(long long, long long) __attribute__((__const__)); long long strtoll(const char * , char ** , int); unsigned long long strtoull(const char * , char ** , int); void _Exit(int) __attribute__((__noreturn__)); # 164 "/usr/include/stdlib.h" 3 int rand_r(unsigned *); int setenv(const char *, const char *, int); void unsetenv(const char *); # 178 "/usr/include/stdlib.h" 3 double drand48(void); double erand48(unsigned short[3]); int getsubopt(char **, char *const *, char **); char *initstate(unsigned long , char *, long); long jrand48(unsigned short[3]); void lcong48(unsigned short[7]); long lrand48(void); int mkstemp(char *); char *mktemp(char *); long mrand48(void); long nrand48(unsigned short[3]); int putenv(const char *); long random(void); char *realpath(const char *, char resolved_path[]); unsigned short *seed48(unsigned short[3]); int setkey(const char *); char *setstate( char *); void srand48(long); void srandom(unsigned long); extern const char *_malloc_options; extern void (*_malloc_message)(const char *, const char *, const char *, const char *); void *alloca(size_t); __uint32_t arc4random(void); void arc4random_addrandom(unsigned char *dat, int datlen); void arc4random_stir(void); char *getbsize(size_t *, long *); char *cgetcap(char *, const char *, int); int cgetclose(void); int cgetent(char **, char **, const char *); int cgetfirst(char **, char **); int cgetmatch(const char *, const char *); int cgetnext(char **, char **); int cgetnum(char *, const char *, long *); int cgetset(const char *); int cgetstr(char *, const char *, char **); int cgetustr(char *, const char *, char **); int daemon(int, int); char *devname(int, int); int getloadavg(double [], int); const char * getprogname(void); int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); int mergesort(void *, size_t, size_t, int (*)(const void *, const void *)); void qsort_r(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); int radixsort(const unsigned char **, int, const unsigned char *, unsigned); void *reallocf(void *, size_t); void setprogname(const char *); int sradixsort(const unsigned char **, int, const unsigned char *, unsigned); void sranddev(void); void srandomdev(void); __int64_t strtoq(const char *, char **, int); __uint64_t strtouq(const char *, char **, int); } # 53 "/usr/include/g++/cstdlib" 2 3 # 84 "/usr/include/g++/cstdlib" 3 namespace std { using ::div_t; using ::ldiv_t; using ::abort; using ::abs; using ::atexit; using ::atof; using ::atoi; using ::atol; using ::bsearch; using ::calloc; using ::div; using ::exit; using ::free; using ::getenv; using ::labs; using ::ldiv; using ::malloc; using ::mblen; using ::mbstowcs; using ::mbtowc; using ::qsort; using ::rand; using ::realloc; using ::srand; using ::strtod; using ::strtol; using ::strtoul; using ::system; using ::wcstombs; using ::wctomb; inline long abs(long __i) { return labs(__i); } inline ldiv_t div(long __i, long __j) { return ldiv(__i, __j); } } # 5 "btree.h" 2 template <class Key, class Element> class BTree { private: class Node; class DataNode; Node *root; public: inline BTree(); inline ~BTree(); inline bool search(Key &, Element &) const; inline bool insert(Key &, Element &); inline bool remove(Key &, Element &); }; # 2 "btree.cpp" 2 template <class Key, class Element> class BTree<Key, Element>::Node { public: Node *left; Node *right; inline Node(); virtual bool search(Key &, Element &) const = 0; virtual bool insert(Node * &, Node * &, Key &, Element &) = 0; virtual bool remove(Node * &, Node * &, Key &, Element &) = 0; protected: unsigned int numElements; }; template <class Key, class Element> inline BTree<Key, Element>::Node::Node() :left(0), right(0), numElements(0) { } template <class Key, class Element> class BTree<Key, Element>::KeyNode : BTree<Key, Element>::Node { public: bool search(Key &, Element &) const; bool insert(Node * &, Node * &, Key &, Element &); private: class NodeItem { public: Key &k; BTree<Key, Element>::Node *child; NodeItem *next; }; NodeItem *preHead; NodeItem *head; NodeItem *tail; NodeItem *splitPoint; KeyNode(Node *); inline NodeItem * _search(Key &k) const { if(k < head->k) return preHead; NodeItem *temp = head; while(temp->next != 0 && temp->next->k >= k) temp = temp->next; return temp; } }; template <class Key, class Element> class BTree<Key, Element>::DataNode : BTree<Key, Element>::Node { public: inline DataNode(); bool search(Key &, Element &) const; bool insert(Node * &, Node * &, Key &, Element &); bool remove(Node * &, Node * &, Key &, Element &); private: class NodeItem { public: Key &k; Element &e; NodeItem *next; }; NodeItem *head; NodeItem *tail; NodeItem *splitPoint; DataNode(Node *); }; template <class Key, class Element> inline BTree<Key, Element>::BTree() { root = new DataNode(); } template <class Key, class Element> inline BTree<Key, Element>::~BTree() { delete root; } template <class Key, class Element> inline bool BTree<Key, Element>::search(Key &k, Element &e) const { return root->search(k, e); } template <class Key, class Element> inline bool BTree<Key, Element>::insert(Key &k, Element &e) { Node *p = root; return root->insert(p, k, e); } template <class Key, class Element> inline bool BTree<Key, Element>::remove(Key &k, Element &e) { Node *p = root; return root->remove(p, k, e); } template <class Key, class Element> BTree<Key, Element>::KeyNode::KeyNode(Node *l) :preHead(l->splitPoint), head(l->splitPoint->next), tail(l->tail) { numElements = l->numElements / 2; left = l; right = l->right, preHead->next = 0; } template <class Key, class Element> bool BTree<Key, Element>::KeyNode::search(Key &k, Element &e) const { return _search(k)->child->search(k, e); } template <class Key, class Element> bool BTree<Key, Element>::KeyNode::insert(Node * &p, Node * &toAdd, Key &k, Element &e) { bool toReturn; NodeItem *temp = _search(k); Node *newNode = 0; toReturn = temp->child->insert(p, newNode, k, e); if(newNode != 0) { numElements++; if(temp == preHead) { preHead->next = head; head = preHead; preHead = new NodeItem(k, newNode, 0); } else { temp->next = new NodeItem(k, newNode, temp->next); if(temp == tail) { tail = temp->next; } } } if(numElements > 7) { Node *newRight = new KeyNode(this); if(right != 0) { right->left = newRight; } right = newRight; if(p == this) { p = new KeyNode(this, newRight); } else { toAdd = newRight; } } return toReturn; } # 221 "btree.cpp" template <class Key, class Element> inline BTree<Key, Element>::DataNode::DataNode() :head(0), tail(0) { } template <class Key, class Element> BTree<Key, Element>::DataNode::DataNode(Node *l) :head(l->splitPoint->next), tail(l->tail) { numElements = l->numElements / 2; left = l; right = l->right, preHead->next = 0; } template <class Key, class Element> bool BTree<Key, Element>::DataNode::search(Key &k, Element &e) const { NodeItem *temp = head; while(temp != 0 && k != temp->k) temp = temp->next; if(temp == 0) { return false; } e = temp->e; return true; } template <class Key, class Element> bool BTree<Key, Element>::DataNode::insert(Node * &p, Node * &toAdd, Key &k, Element &e) { bool toReturn; if(head == 0) { head = new NodeItem(); head->k = k; head->e = e; head->next = 0; } else { NodeItem *temp = head; while(temp->next != 0 && k <= temp->k) temp = temp->next; if(k == temp->k) { return false; } NodeItem *toInsert = new NodeItem(); toInsert->k = k; toInsert->e = e; if(temp == head) { toInsert->next = head; head = toInsert; } else if(temp == tail) { tail->next = toInsert; tail = toInsert; } else { toInsert->next = temp->next->next; temp->next = toInsert; } } toReturn = true; if(numElements > 7) { Node *newRight = new DataNode(this); if(right != 0) { right->left = newRight; } right = newRight; if(p == this) { p = new KeyNode(this, newRight); } else { toAdd = newRight; } } return toReturn; }
next reply other threads:[~2002-11-13 18:16 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-11-19 18:39 galen_sampson [this message] 2002-11-19 18:56 bangerth 2002-11-20 2:46 reichelt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20021113181007.20029.qmail@sources.redhat.com \ --to=galen_sampson@yahoo.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).