Serious code generation bug introduced in latest snapshot (egcs-2.92.18)
Roberto Bagnara
bagnara@di.unipi.it
Mon Nov 2 17:22:00 GMT 1998
The following snippet (preprocessed source attached)
reveals a code generation bug introduced
in egcs-2.92.18. In other words, egcs-2.92.17 is fine in this
respect.
In summary, the class PatternArgs contains a vector of dimension
1 of PatternPtr, PatternPtr patterns[1].
PatternPtr is a shorthand for MHeapPtr<Pattern>, where MHeapPtr
is a templatized class of smart pointers.
The code generated for the sizing constructor
PatternArgs::PatternArgs(int arity) should contain
the initialization of the only element of patterns[1].
This initialization consists in calling
MHeapPtr<Pattern>::MHeapPtr().
Here is an excerpt of the side by side diff of the asms
obtained with egcs-2.92.17 (on the left)
and with egcs-2.92.18 (on the right).
The culprit is marked with "<<<< HERE".
egcs-2.92.18 produces a conditional jump instruction
"je" instead of "jl". This results in the initialization
loop being executed 0 times, which is incorrect.
PatternArgs::PatternArgs(int): PatternArgs::PatternArgs(int):
pushl %ebp pushl %ebp
movl %esp,%ebp movl %esp,%ebp
subl $8,%esp subl $8,%esp
pushl %edi pushl %edi
pushl %esi pushl %esi
pushl %ebx pushl %ebx
movl 8(%ebp),%ebx movl 8(%ebp),%ebx
movl 12(%ebp),%eax movl 12(%ebp),%eax
movl %eax,(%ebx) movl %eax,(%ebx)
xorl %esi,%esi <
leal 4(%ebx),%esi leal 4(%ebx),%esi
leal 4(%ebx),%ecx | movl %esi,%eax
movl %ecx,-8(%ebp) | leal 4(%ebx),%eax
> movl %eax,-8(%ebp)
movl -8(%ebp),%eax movl -8(%ebp),%eax
xorl %edi,%edi xorl %edi,%edi
testl %edi,%edi testl %edi,%edi
jl .L15 | je .L15 <<<< HERE
.p2align 4,,7 .p2align 4,,7
.L16: .L16:
movl -8(%ebp),%ecx | movl -8(%ebp),%eax
pushl %ecx | pushl %eax
call MHeapPtr<Pattern>::MHeapPtr(void) call
MHeapPtr<Pattern>::MHeapPtr(void)
addl $4,%esp addl $4,%esp
addl $4,-8(%ebp) addl $4,-8(%ebp)
.L18: .L18:
decl %edi decl %edi
cmpl $-1,%edi cmpl $-1,%edi
jne .L21 jne .L21
jmp .L15 jmp .L15
.p2align 4,,7 .p2align 4,,7
.L21: .L21:
jmp .L16 jmp .L16
.p2align 4,,7 .p2align 4,,7
.L17: .L17:
.L15: .L15:
Here is some more info on my configuration and on how
I do reproduce the problem.
$ uname -a
Linux zoltan.unisuv.it 2.0.35 #8 Sun Nov 1 16:16:21 CET 1998 i586 unknown
$ /usr/local/beta/bin/g++ -v
Reading specs from
/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.18/specs
gcc version egcs-2.92.18 19981101 (gcc2 ss-980609 experimental)
$ /usr/local/beta/bin/g++ -Vegcs-2.92.17 -v
Reading specs from
/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/specs
gcc driver version egcs-2.92.18 19981101 (gcc2 ss-980609 experimental) executing
gcc version egcs-2.92.17
g++: No input files
The left column above was produced with
$ /usr/local/beta/bin/g++ -Vegcs-2.92.17 -DNDEBUG=1 -Wall -W -fno-exceptions -S
bug.ii
the right column with
/usr/local/beta/bin/g++ -DNDEBUG=1 -Wall -W -fno-exceptions -S bug.ii
Here is the original source, just in case.
The preprocessed source is given as attachment.
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#define PLNEW(pl, class, args...) new ## pl class ## args
#define PLNEW1(pl, class, as_class, args...) new ## pl class ## args
#define NEW(class, args...) new class ## args
#define NEW1(class, as_class, args...) new class ## args
#define NEW_ARY(class, size) new class[size]
#define DELETE(ptr) delete ptr
#define DELETE_ARY(ptr) delete [] ptr
#define COUNTER_DEF(T...)
class RefCounted_Object {
public:
mutable unsigned long ref_count;
RefCounted_Object()
: ref_count(0) {
}
RefCounted_Object(const RefCounted_Object&)
: ref_count(0) {
}
void operator=(const RefCounted_Object&) const {
}
~RefCounted_Object() {
assert(ref_count == 0);
}
void new_ref() const {
++ref_count;
}
// Return true if object can be deleted.
bool del_ref() const {
return --ref_count == 0;
}
bool referenced_once() const {
return ref_count == 1;
}
bool unreferenced() const {
return ref_count == 0;
}
};
template <class T>
class MHeapPtr {
private:
T *ptr;
void new_ref() const {
if (ptr)
ptr->new_ref();
}
bool del_ref() const {
if (ptr)
return ptr->del_ref();
else
return false;
}
public:
MHeapPtr()
: ptr(0) {
}
MHeapPtr(const MHeapPtr& p)
: ptr(p.ptr) {
new_ref();
}
MHeapPtr(T* p)
: ptr(p) {
new_ref();
}
void ctor(T* p) {
assert(ptr == 0);
ptr = p;
new_ref();
}
~MHeapPtr() {
if (del_ref())
DELETE(ptr);
}
MHeapPtr& operator=(const MHeapPtr& p) {
if (ptr != p.ptr) {
T *old = ptr;
ptr = p.ptr;
new_ref();
if (old && old->del_ref())
DELETE(old);
}
return *this;
}
MHeapPtr& operator=(T* p) {
if (ptr != p) {
T *old = ptr;
ptr = p;
new_ref();
if (old && old->del_ref())
DELETE(old);
}
return *this;
}
T& operator*() const {
assert(ptr != 0);
return *ptr;
}
T* operator->() const {
assert(ptr != 0);
return ptr;
}
int ref_count() const {
return ptr == 0 ? 0 : ptr->ref_count;
}
bool operator ==(const MHeapPtr& p) const {
return ptr == p.ptr;
}
bool operator !=(const MHeapPtr& p) const {
return ptr != p.ptr;
}
bool operator <(const MHeapPtr& p) const {
return ptr < p.ptr;
}
bool operator <=(const MHeapPtr& p) const {
return ptr <= p.ptr;
}
bool operator >(const MHeapPtr& p) const {
return ptr > p.ptr;
}
bool operator >=(const MHeapPtr& p) const {
return ptr >= p.ptr;
}
T* operator()() const {
return ptr;
}
};
class Pattern : public RefCounted_Object {
};
typedef MHeapPtr<Pattern> PatternPtr;
class PatternArgs {
private:
int sz;
PatternPtr patterns[1];
public:
// Sizing ctor
explicit PatternArgs(int arity);
};
PatternArgs::PatternArgs(int arity)
: sz(arity)
{
int extra = sz-1;
if (extra > 0)
memset(patterns+1, 0, extra*sizeof(PatternPtr));
}
Keep up the extra good work.
Roberto
--
Roberto Bagnara
Department of Mathematics, University of Parma, Italy
http://www.di.unipi.it/~bagnara/bagnara.html
mailto:bagnara@di.unipi.it
# 1 "bug.cc"
# 1 "/usr/include/string.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 117 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 222 "/usr/include/features.h" 3
# 22 "/usr/include/sys/cdefs.h" 2 3
# 54 "/usr/include/sys/cdefs.h" 3
# 86 "/usr/include/sys/cdefs.h" 3
# 205 "/usr/include/features.h" 2 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 219 "/usr/include/features.h" 2 3
# 26 "/usr/include/string.h" 2 3
extern "C" {
# 1 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 1 3
# 19 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 61 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 131 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
typedef unsigned int size_t;
# 271 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 283 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 317 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 33 "/usr/include/string.h" 2 3
extern void * memcpy (void * __dest, __const void * __src,
size_t __n) ;
extern void * memmove (void * __dest, __const void * __src,
size_t __n) ;
extern void * __memccpy (void * __dest, __const void * __src,
int __c, size_t __n) ;
extern void * memccpy (void * __dest, __const void * __src,
int __c, size_t __n) ;
extern void * memset (void * __s, int __c, size_t __n) ;
extern int memcmp (__const void * __s1, __const void * __s2,
size_t __n) ;
extern void * memchr (__const void * __s, int __c, size_t __n) ;
extern char *strcpy (char *__dest, __const char *__src) ;
extern char *strncpy (char *__dest, __const char *__src, size_t __n) ;
extern char *strcat (char *__dest, __const char *__src) ;
extern char *strncat (char *__dest, __const char *__src, size_t __n) ;
extern int strcmp (__const char *__s1, __const char *__s2) ;
extern int strncmp (__const char *__s1, __const char *__s2, size_t __n) ;
extern int strcoll (__const char *__s1, __const char *__s2) ;
extern size_t strxfrm (char *__dest, __const char *__src, size_t __n) ;
extern char *__strdup (__const char *__s) ;
extern char *strdup (__const char *__s) ;
extern char *__strndup (__const char *__string, size_t __n) ;
# 121 "/usr/include/string.h" 3
extern char *strchr (__const char *__s, int __c) ;
extern char *strrchr (__const char *__s, int __c) ;
extern size_t strcspn (__const char *__s, __const char *__reject) ;
extern size_t strspn (__const char *__s, __const char *__accept) ;
extern char *strpbrk (__const char *__s, __const char *__accept) ;
extern char *strstr (__const char *__haystack, __const char *__needle) ;
extern char *strtok (char *__s, __const char *__delim) ;
extern char *strtok_r (char *__s, __const char *__delim,
char **__save_ptr) ;
extern size_t strlen (__const char *__s) ;
# 173 "/usr/include/string.h" 3
extern char *strerror (int __errnum) ;
extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen) ;
extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) ;
extern void bcopy (__const void * __src, void * __dest, size_t __n) ;
extern void bzero (void * __s, size_t __n) ;
extern int bcmp (__const void * __s1, __const void * __s2, size_t __n) ;
extern char *index (__const char *__s, int __c) ;
extern char *rindex (__const char *__s, int __c) ;
extern int ffs (int __i) ;
extern int __strcasecmp (__const char *__s1, __const char *__s2) ;
extern int strcasecmp (__const char *__s1, __const char *__s2) ;
extern int __strncasecmp (__const char *__s1, __const char *__s2,
size_t __n) ;
extern int strncasecmp (__const char *__s1, __const char *__s2,
size_t __n) ;
extern char *__strsep (char **__stringp, __const char *__delim) ;
extern char *strsep (char **__stringp, __const char *__delim) ;
# 241 "/usr/include/string.h" 3
extern char *basename (__const char *__filename) ;
}
# 97 "bug.cc" 2
# 1 "/usr/include/assert.h" 1 3
# 32 "/usr/include/assert.h" 3
# 99 "/usr/include/assert.h" 3
# 98 "bug.cc" 2
# 1 "/usr/include/stdlib.h" 1 3
# 1 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 1 3
# 19 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 61 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 131 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 188 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 283 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 317 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 32 "/usr/include/stdlib.h" 2 3
extern "C" {
typedef struct
{
int quot;
int rem;
} div_t;
typedef struct
{
long int quot;
long int rem;
} ldiv_t;
extern int __ctype_get_mb_cur_max (void) ;
extern double atof (__const char *__nptr) ;
extern int atoi (__const char *__nptr) ;
extern long int atol (__const char *__nptr) ;
extern long long int atoll (__const char *__nptr) ;
extern double strtod (__const char *__nptr, char **__endptr) ;
extern long int strtol (__const char *__nptr, char **__endptr,
int __base) ;
extern unsigned long int strtoul (__const char *__nptr,
char **__endptr, int __base) ;
extern long long int strtoq (__const char *__nptr, char **__endptr,
int __base) ;
extern unsigned long long int strtouq (__const char *__nptr,
char **__endptr, int __base) ;
extern long long int strtoll (__const char *__nptr, char **__endptr,
int __base) ;
extern unsigned long long int strtoull (__const char *__nptr,
char **__endptr, int __base) ;
extern double __strtod_internal (__const char *__nptr,
char **__endptr, int __group) ;
extern float __strtof_internal (__const char *__nptr, char **__endptr,
int __group) ;
extern long double __strtold_internal (__const char *__nptr,
char **__endptr, int __group) ;
extern long int __strtol_internal (__const char *__nptr, char **__endptr,
int __base, int __group) ;
extern unsigned long int __strtoul_internal (__const char *__nptr,
char **__endptr, int __base,
int __group) ;
extern long long int __strtoq_internal (__const char *__nptr,
char **__endptr, int __base,
int __group) ;
extern unsigned long long int __strtouq_internal (__const char *__nptr,
char **__endptr,
int __base,
int __group) ;
# 197 "/usr/include/stdlib.h" 3
extern char *l64a (long int __n) ;
extern long int a64l (__const char *__s) ;
# 1 "/usr/include/sys/types.h" 1 3
extern "C" {
# 1 "/usr/include/gnu/types.h" 1 3
typedef unsigned char __u_char;
typedef unsigned short __u_short;
typedef unsigned int __u_int;
typedef unsigned long __u_long;
typedef unsigned long long int __u_quad_t;
typedef long long int __quad_t;
# 41 "/usr/include/gnu/types.h" 3
typedef __quad_t *__qaddr_t;
typedef __u_quad_t __dev_t;
typedef __u_int __uid_t;
typedef __u_int __gid_t;
typedef __u_long __ino_t;
typedef __u_int __mode_t;
typedef __u_int __nlink_t;
typedef long int __off_t;
typedef __quad_t __loff_t;
typedef int __pid_t;
typedef int __ssize_t;
typedef struct
{
int __val[2];
} __fsid_t;
typedef int __daddr_t;
typedef char *__caddr_t;
typedef long int __time_t;
typedef long int __swblk_t;
typedef long int __clock_t;
typedef unsigned long int __fd_mask;
typedef struct
{
__fd_mask fds_bits[1024 / (8 * sizeof (__fd_mask)) ];
} __fd_set;
typedef int __key_t;
typedef unsigned short int __ipc_pid_t;
# 30 "/usr/include/sys/types.h" 2 3
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
typedef __dev_t dev_t;
typedef __gid_t gid_t;
typedef __ino_t ino_t;
typedef __mode_t mode_t;
typedef __nlink_t nlink_t;
typedef __off_t off_t;
typedef __loff_t loff_t;
typedef __pid_t pid_t;
typedef __uid_t uid_t;
typedef __ssize_t ssize_t;
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
typedef __key_t key_t;
# 1 "/usr/include/time.h" 1 3
# 56 "/usr/include/time.h" 3
# 68 "/usr/include/time.h" 3
typedef __time_t time_t;
# 97 "/usr/include/time.h" 3
# 125 "/usr/include/time.h" 3
# 281 "/usr/include/time.h" 3
# 67 "/usr/include/sys/types.h" 2 3
# 1 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 1 3
# 19 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 61 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 131 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 188 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 271 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 283 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 317 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 70 "/usr/include/sys/types.h" 2 3
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
# 95 "/usr/include/sys/types.h" 3
typedef int int8_t __attribute__ ((__mode__ ( __QI__ ))) ;
typedef unsigned int u_int8_t __attribute__ ((__mode__ ( __QI__ ))) ;
typedef int int16_t __attribute__ ((__mode__ ( __HI__ ))) ;
typedef unsigned int u_int16_t __attribute__ ((__mode__ ( __HI__ ))) ;
typedef int int32_t __attribute__ ((__mode__ ( __SI__ ))) ;
typedef unsigned int u_int32_t __attribute__ ((__mode__ ( __SI__ ))) ;
typedef int int64_t __attribute__ ((__mode__ ( __DI__ ))) ;
typedef unsigned int u_int64_t __attribute__ ((__mode__ ( __DI__ ))) ;
typedef int register_t __attribute__ ((__mode__ (__word__)));
# 1 "/usr/include/endian.h" 1 3
# 1 "/usr/include/bytesex.h" 1 3
# 34 "/usr/include/endian.h" 2 3
# 123 "/usr/include/sys/types.h" 2 3
# 1 "/usr/include/sys/select.h" 1 3
# 1 "/usr/include/selectbits.h" 1 3
# 50 "/usr/include/selectbits.h" 3
# 65 "/usr/include/selectbits.h" 3
# 31 "/usr/include/sys/select.h" 2 3
# 1 "/usr/include/time.h" 1 3
# 56 "/usr/include/time.h" 3
# 68 "/usr/include/time.h" 3
# 80 "/usr/include/time.h" 3
struct timespec
{
long int tv_sec;
long int tv_nsec;
};
# 125 "/usr/include/time.h" 3
# 281 "/usr/include/time.h" 3
# 35 "/usr/include/sys/select.h" 2 3
extern "C" {
struct timeval;
typedef __fd_mask fd_mask;
typedef __fd_set fd_set;
extern int __select (int __nfds, __fd_set *__readfds,
__fd_set *__writefds, __fd_set *__exceptfds,
struct timeval *__timeout) ;
extern int select (int __nfds, __fd_set *__readfds,
__fd_set *__writefds, __fd_set *__exceptfds,
struct timeval *__timeout) ;
extern int __pselect (int __nfds, __fd_set *__readfds,
__fd_set *__writefds, __fd_set *__exceptfds,
struct timespec *__timeout) ;
extern int pselect (int __nfds, __fd_set *__readfds,
__fd_set *__writefds, __fd_set *__exceptfds,
struct timespec *__timeout) ;
}
# 126 "/usr/include/sys/types.h" 2 3
}
# 210 "/usr/include/stdlib.h" 2 3
extern int32_t __random (void) ;
extern int32_t random (void) ;
extern void __srandom (unsigned int __seed) ;
extern void srandom (unsigned int __seed) ;
extern void * __initstate (unsigned int __seed, void * __statebuf,
size_t __statelen) ;
extern void * initstate (unsigned int __seed, void * __statebuf,
size_t __statelen) ;
extern void * __setstate (void * __statebuf) ;
extern void * setstate (void * __statebuf) ;
struct random_data
{
int32_t *fptr;
int32_t *rptr;
int32_t *state;
int rand_type;
int rand_deg;
int rand_sep;
int32_t *end_ptr;
};
extern int __random_r (struct random_data *__buf, int32_t *__result) ;
extern int random_r (struct random_data *__buf, int32_t *__result) ;
extern int __srandom_r (unsigned int __seed, struct random_data *__buf) ;
extern int srandom_r (unsigned int __seed, struct random_data *__buf) ;
extern int __initstate_r (unsigned int __seed, void * __statebuf,
size_t __statelen, struct random_data *__buf) ;
extern int initstate_r (unsigned int __seed, void * __statebuf,
size_t __statelen, struct random_data *__buf) ;
extern int __setstate_r (void * __statebuf, struct random_data *__buf) ;
extern int setstate_r (void * __statebuf, struct random_data *__buf) ;
extern int rand (void) ;
extern void srand (unsigned int __seed) ;
extern int __rand_r (unsigned int *__seed) ;
extern int rand_r (unsigned int *__seed) ;
extern double drand48 (void) ;
extern double erand48 (unsigned short int __xsubi[3]) ;
extern long lrand48 (void) ;
extern long nrand48 (unsigned short int __xsubi[3]) ;
extern long mrand48 (void) ;
extern long jrand48 (unsigned short int __xsubi[3]) ;
extern void srand48 (long __seedval) ;
extern unsigned short int *seed48 (unsigned short int __seed16v[3]) ;
extern void lcong48 (unsigned short int __param[7]) ;
struct drand48_data
{
unsigned short int x[3];
unsigned short int a[3];
unsigned short int c;
unsigned short int old_x[3];
int init;
};
extern int drand48_r (struct drand48_data *__buffer, double *__result) ;
extern int erand48_r (unsigned short int __xsubi[3],
struct drand48_data *__buffer, double *__result) ;
extern int lrand48_r (struct drand48_data *__buffer, long *__result) ;
extern int nrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__buffer, long *__result) ;
extern int mrand48_r (struct drand48_data *__buffer, long *__result) ;
extern int jrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__buffer, long *__result) ;
extern int srand48_r (long __seedval, struct drand48_data *__buffer) ;
extern int seed48_r (unsigned short int __seed16v[3],
struct drand48_data *__buffer) ;
extern int lcong48_r (unsigned short int __param[7],
struct drand48_data *__buffer) ;
extern int __drand48_iterate (unsigned short int __xsubi[3],
struct drand48_data *__buffer) ;
extern void * malloc (size_t __size) ;
extern void * realloc (void * __ptr, size_t __size) ;
extern void * calloc (size_t __nmemb, size_t __size) ;
extern void free (void * __ptr) ;
extern void cfree (void * __ptr) ;
# 1 "/usr/include/alloca.h" 1 3
# 1 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 1 3
# 19 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 61 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 131 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 188 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 271 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 283 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 317 "/usr/local/beta/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.92.17/include/stddef.h" 3
# 25 "/usr/include/alloca.h" 2 3
extern "C" {
extern void * __alloca (size_t __size) ;
extern void * alloca (size_t __size) ;
}
# 360 "/usr/include/stdlib.h" 2 3
extern void * valloc (size_t __size) ;
extern void abort (void) __attribute__ ((__noreturn__));
extern int atexit (void (*__func) (void)) ;
extern int __on_exit (void (*__func) (int __status, void * __arg),
void * __arg) ;
extern int on_exit (void (*__func) (int __status, void * __arg),
void * __arg) ;
extern void exit (int __status) __attribute__ ((__noreturn__));
extern char *getenv (__const char *__name) ;
extern char *__secure_getenv (__const char *__name) ;
extern int putenv (__const char *__string) ;
extern int setenv (__const char *__name, __const char *__value,
int __replace) ;
extern void unsetenv (__const char *__name) ;
extern int __clearenv (void) ;
extern int clearenv (void) ;
extern char *mktemp (char *__template) ;
extern int mkstemp (char *__template) ;
extern int system (__const char *__command) ;
extern char *realpath (__const char *__name, char *__resolved) ;
typedef int (*__compar_fn_t) (__const void * , __const void * ) ;
extern void * bsearch (__const void * __key, __const void * __base,
size_t __nmemb, size_t __size,
__compar_fn_t __compar) ;
extern void qsort (void * __base, size_t __nmemb, size_t __size,
__compar_fn_t __compar) ;
extern int abs (int __x) __attribute__ ((__const__));
extern long int labs (long int __x) __attribute__ ((__const__));
extern div_t div (int __numer, int __denom) __attribute__ ((__const__));
extern ldiv_t ldiv (long int __numer, long int __denom) __attribute__ ((__const__));
extern char *ecvt (double __value, int __ndigit, int *__decpt,
int *__sign) ;
extern char *fcvt (double __value, int __ndigit, int *__decpt,
int *__sign) ;
extern char *gcvt (double __value, int __ndigit, char *__buf) ;
extern char *qecvt (long double __value, int __ndigit, int *__decpt,
int *__sign) ;
extern char *qfcvt (long double __value, int __ndigit, int *__decpt,
int *__sign) ;
extern char *qgcvt (long double __value, int __ndigit, char *__buf) ;
extern int ecvt_r (double __value, int __ndigit, int *__decpt,
int *__sign, char *__buf, size_t __len) ;
extern int fcvt_r (double __value, int __ndigit, int *__decpt,
int *__sign, char *__buf, size_t __len) ;
extern int qecvt_r (long double __value, int __ndigit, int *__decpt,
int *__sign, char *__buf, size_t __len) ;
extern int qfcvt_r (long double __value, int __ndigit, int *__decpt,
int *__sign, char *__buf, size_t __len) ;
extern int mblen (__const char *__s, size_t __n) ;
extern int mbtowc (wchar_t *__pwc, __const char *__s, size_t __n) ;
extern int wctomb (char *__s, wchar_t __wchar) ;
extern size_t mbstowcs (wchar_t *__pwcs, __const char *__s, size_t __n) ;
extern size_t wcstombs (char *__s, __const wchar_t *__pwcs, size_t __n) ;
extern int rpmatch (__const char *__response) ;
# 582 "/usr/include/stdlib.h" 3
}
# 99 "bug.cc" 2
class RefCounted_Object {
public:
mutable unsigned long ref_count;
RefCounted_Object()
: ref_count(0) {
}
RefCounted_Object(const RefCounted_Object&)
: ref_count(0) {
}
void operator=(const RefCounted_Object&) const {
}
~RefCounted_Object() {
((void) 0) ;
}
void new_ref() const {
++ref_count;
}
bool del_ref() const {
return --ref_count == 0;
}
bool referenced_once() const {
return ref_count == 1;
}
bool unreferenced() const {
return ref_count == 0;
}
};
template <class T>
class MHeapPtr {
private:
T *ptr;
void new_ref() const {
if (ptr)
ptr->new_ref();
}
bool del_ref() const {
if (ptr)
return ptr->del_ref();
else
return false;
}
public:
MHeapPtr()
: ptr(0) {
}
MHeapPtr(const MHeapPtr& p)
: ptr(p.ptr) {
new_ref();
}
MHeapPtr(T* p)
: ptr(p) {
new_ref();
}
void ctor(T* p) {
((void) 0) ;
ptr = p;
new_ref();
}
~MHeapPtr() {
if (del_ref())
delete ptr ;
}
MHeapPtr& operator=(const MHeapPtr& p) {
if (ptr != p.ptr) {
T *old = ptr;
ptr = p.ptr;
new_ref();
if (old && old->del_ref())
delete old ;
}
return *this;
}
MHeapPtr& operator=(T* p) {
if (ptr != p) {
T *old = ptr;
ptr = p;
new_ref();
if (old && old->del_ref())
delete old ;
}
return *this;
}
T& operator*() const {
((void) 0) ;
return *ptr;
}
T* operator->() const {
((void) 0) ;
return ptr;
}
int ref_count() const {
return ptr == 0 ? 0 : ptr->ref_count;
}
bool operator ==(const MHeapPtr& p) const {
return ptr == p.ptr;
}
bool operator !=(const MHeapPtr& p) const {
return ptr != p.ptr;
}
bool operator <(const MHeapPtr& p) const {
return ptr < p.ptr;
}
bool operator <=(const MHeapPtr& p) const {
return ptr <= p.ptr;
}
bool operator >(const MHeapPtr& p) const {
return ptr > p.ptr;
}
bool operator >=(const MHeapPtr& p) const {
return ptr >= p.ptr;
}
T* operator()() const {
return ptr;
}
};
class Pattern : public RefCounted_Object {
};
typedef MHeapPtr<Pattern> PatternPtr;
class PatternArgs {
private:
int sz;
PatternPtr patterns[1];
public:
explicit PatternArgs(int arity);
};
PatternArgs::PatternArgs(int arity)
: sz(arity)
{
int extra = sz-1;
if (extra > 0)
memset(patterns+1, 0, extra*sizeof(PatternPtr));
}
More information about the Gcc-bugs
mailing list