bad inlining
Steven Parkes
parkes@sierravista.com
Thu Jul 16 02:42:00 GMT 1998
Probably related to c++ front end, possibly related to templates.
The attached file, when compiled -finline -O, produces bad results.
This has been verified on i386-pc-sunos5 and hppa-hp-hpux10.
It fails in egcs-19980715 and has been failing for a few months.
The problem is related to a deeply inlined trivial function, Chain<>::headOf.
If this function is outlined, the code is correct (set the ifdef in the
sample to 0).
The function and the functions it calls are inlined incorrectly.
The correct result of the set of functions is a word dereference of the
`this' pointer. However, when inlined, `this' doesn't get dereferenced;
`this' itself is used.
The assembly below shows the problem. The two sequences differ only
in headOf being outlined. In the inline case, the call of headOf is
removed but no dereference is substituted.
I haven't been able to get this happen on a more simple example.
Code that has one less level of inlining but otherwise is very similar
doesn't seem to exhibit the problems.
Bad body:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
pushl %eax
pushl $.LC1
call printf
pushl %ebx
call SVR::CLC::STL::Containers::Linked::clear(void)
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret
Good body:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
pushl %ebx
call Chain<int>::headOf(void) const
pushl %eax
pushl $.LC1
call printf
pushl %ebx
call SVR::CLC::STL::Containers::Linked::clear(void)
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret
Code:
static char const *RCS_id()
{return "$InstanceHeader: SVR/CLC/STL/Containers/templates/ChI.C$\n"
"";}
class svr_bool;
struct SVR {
struct CLC;
struct Verity;
struct Nexus;
};
struct SVR::CLC {
struct LSL;
struct APA;
struct STL;
struct AIF;
};
struct SVR::CLC::LSL {
struct Port;
struct Feature;
struct Diagnostic;
struct RTTI;
struct Types;
struct Memory;
struct Functional;
struct IO;
struct FreeStore;
struct CData;
};
extern "C" {
}
extern "C" {
extern long _sysconf(int);
}
extern "C" {
}
extern "C" {
typedef struct _physadr_t { int r[1]; } *physadr_t;
typedef struct _label_t { int val[6]; } label_t;
typedef unsigned char lock_t;
}
extern "C" {
typedef unsigned char uchar_t;
typedef unsigned short ushort_t;
typedef unsigned int uint_t;
typedef unsigned long ulong_t;
typedef char * caddr_t;
typedef long daddr_t;
typedef long off_t;
typedef short cnt_t;
typedef ulong_t paddr_t;
typedef uchar_t use_t;
typedef short sysid_t;
typedef short index_t;
typedef enum { B_FALSE, B_TRUE } boolean_t;
typedef long long longlong_t;
typedef unsigned long long u_longlong_t;
typedef longlong_t offset_t;
typedef longlong_t diskaddr_t;
typedef union {
offset_t _f;
struct {
off_t _l;
long _u;
} _p;
} lloff_t;
typedef union {
diskaddr_t _f;
struct {
daddr_t _l;
long _u;
} _p;
} lldaddr_t;
typedef ulong_t k_fltset_t;
typedef long id_t;
typedef ulong_t major_t;
typedef ulong_t minor_t;
typedef short pri_t;
typedef ushort_t o_mode_t;
typedef short o_dev_t;
typedef ushort_t o_uid_t;
typedef o_uid_t o_gid_t;
typedef short o_nlink_t;
typedef short o_pid_t;
typedef ushort_t o_ino_t;
typedef int key_t;
typedef ulong_t mode_t;
typedef long uid_t;
typedef uid_t gid_t;
typedef ulong_t nlink_t;
typedef ulong_t dev_t;
typedef ulong_t ino_t;
typedef long pid_t;
typedef uint_t size_t;
typedef int ssize_t;
typedef long time_t;
typedef long clock_t;
typedef int clockid_t;
typedef int timer_t;
typedef unsigned char unchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef long hostid_t;
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef struct _quad { long val[2]; } quad;
extern "C" {
struct timeval {
long tv_sec;
long tv_usec;
};
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
}
extern "C" {
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
typedef struct timespec {
time_t tv_sec;
long tv_nsec;
} timespec_t;
typedef struct timespec timestruc_t;
typedef struct itimerspec {
struct timespec it_interval;
struct timespec it_value;
} itimerspec_t;
typedef longlong_t hrtime_t;
int adjtime(struct timeval *, struct timeval *);
int getitimer(int, struct itimerval *);
int setitimer(int, const struct itimerval *, struct itimerval *);
int gettimeofday(struct timeval *, void *);
int settimeofday(struct timeval *, void *);
hrtime_t gethrtime(void);
hrtime_t gethrvtime(void);
extern "C" {
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
extern clock_t clock(void);
extern double difftime(time_t, time_t);
extern time_t mktime(struct tm *);
extern time_t time(time_t *);
extern char *asctime(const struct tm *);
extern char *ctime(const time_t *);
extern struct tm *gmtime(const time_t *);
extern struct tm *localtime(const time_t *);
extern size_t strftime(char *, size_t, const char *, const struct tm *);
extern char *strptime(const char *, const char *, struct tm *);
extern "C" {
union sigval {
int sival_int;
void *sival_ptr;
};
struct sigevent {
int sigev_notify;
union {
int _sigev_signo;
void (*_sigev_notify_function)(union sigval);
} _sigev_un;
union sigval sigev_value;
int _sigev_pad1;
void *_sigev_notify_attributes;
int _sigev_pad2;
};
extern "C" {
extern "C" {
typedef int faultcode_t;
}
}
typedef struct
siginfo
{
int si_signo;
int si_code;
int si_errno;
union {
int _pad[((128 / sizeof (int)) - 3) ];
struct {
pid_t _pid;
union {
struct {
uid_t _uid;
union sigval _value;
} _kill;
struct {
clock_t _utime;
int _status;
clock_t _stime;
} _cld;
} _pdata;
} _proc;
struct {
caddr_t _addr;
int _trapno;
} _fault;
struct {
int _fd;
long _band;
} _file;
struct {
caddr_t _faddr;
timestruc_t _tstamp;
short _syscall;
char _nsysarg;
char _fault;
long _sysarg[8];
long _mstate[17];
} _prof;
} _data;
} siginfo_t;
typedef struct k_siginfo {
int si_signo;
int si_code;
int si_errno;
union {
struct {
pid_t _pid;
union {
struct {
uid_t _uid;
union sigval _value;
} _kill;
struct {
clock_t _utime;
int _status;
clock_t _stime;
} _cld;
} _pdata;
} _proc;
struct {
caddr_t _addr;
int _trapno;
} _fault;
struct {
int _fd;
long _band;
} _file;
struct {
caddr_t _faddr;
timestruc_t _tstamp;
short _syscall;
char _nsysarg;
char _fault;
} _prof;
} _data;
} k_siginfo_t;
typedef struct sigqueue {
struct sigqueue *sq_next;
k_siginfo_t sq_info;
void (*sq_func)(struct sigqueue *);
void *sq_backptr;
} sigqueue_t;
}
extern int clock_getres(clockid_t, struct timespec *);
extern int clock_gettime(clockid_t, struct timespec *);
extern int clock_settime(clockid_t, const struct timespec *);
extern int timer_create(clockid_t, struct sigevent *, timer_t *);
extern int timer_delete(timer_t);
extern int timer_getoverrun(timer_t);
extern int timer_gettime(timer_t, struct itimerspec *);
extern int timer_settime(timer_t, int, const struct itimerspec *,
struct itimerspec *);
extern int nanosleep(const struct timespec *, struct timespec *);
extern void tzset(void);
extern char *tzname[2];
extern long timezone;
extern int daylight;
extern int cftime(char *, char *, const time_t *);
extern int ascftime(char *, const char *, const struct tm *);
extern long altzone;
extern struct tm *getdate(const char *);
extern int getdate_err;
}
}
extern "C" {
typedef long fd_mask;
typedef struct fd_set {
fd_mask fds_bits[((( 1024 )+(( (sizeof (fd_mask) * 8 ) )-1))/( (sizeof (fd_mask) * 8 ) )) ];
} fd_set;
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
}
}
extern "C" {
}
extern "C" {
}
extern "C" {
extern long _sysconf(int);
}
struct SVR::CLC::LSL::Types {
class AlignedType;
class UUId;
class Data;
class DateTime;
class DateTimeInterval;
typedef unsigned char Octet;
};
struct SVR::CLC::LSL::RTTI {
class PointerGeneric;
class ReferenceGeneric;
class HandleGeneric;
class ValueGeneric;
class Literal;
class TypeInfo;
class TypeIDBase;
class TypeIDGeneric;
class MetaClassGeneric;
class Capability;
class CapabilityName;
class CapabilityIterator;
class Allocatable;
class Initializable;
class NullInitializable;
class ZeroInitializable;
class ConvertibleFrom;
class Copyable;
class BitwiseCopyable;
class Assignable;
class BitwiseAssignable;
class Destructible;
class NullDestructible;
class Equatable;
class BitwiseEquatable;
class DynamicallyTyped;
class ParsableFrom;
class RenderableAs;
class Incapable;
class HashTable;
};
template <class T> class TypeID;
template <class T> class TypeIDInit;
template <class T> class MetaClass;
template <class T> class NameInfo;
template <class X, class T, class Dummy> class TemplateInfo1;
template <class X, class T1, class T2, class Dummy> class TemplateInfo2;
template <class X, class T1, class T2, class T3, class Dummy> class TemplateInfo3;
template <class X, class T1, class T2, class T3, class T4, class Dummy> class TemplateInfo4;
template <class X, class T1, class T2, class T3, class T4, class T5, class Dummy> class TemplateInfo5;
template <class T> class AllocatableClass;
template <class T> class InitializableClass;
template <class T> class NullInitializableClass;
template <class T> class ZeroInitializableClass;
template <class T> class CopyableClass;
template <class T> class BitwiseCopyableClass;
template <class T> class AssignableClass;
template <class T> class BitwiseAssignableClass;
template <class T> class DestructibleClass;
template <class T> class NullDestructibleClass;
template <class T> class EquatableClass;
template <class T> class BitwiseEquatableClass;
template <class T> class DynamicallyTypedClass;
template <class T> class POD;
template <class T> class Class;
template <class T> class PolymorphicClass;
template <class T> class AbstractClass;
enum svrFeatureStatus {
svr_yes = 1,
svr_no = -1,
svr_all = 2,
svr_none = -2,
svr_feature_invalid = 0
};
extern "C" {
svrFeatureStatus
svr_feature_union( svrFeatureStatus, svrFeatureStatus )
; } ;
extern "C" {
svrFeatureStatus
svr_feature_invert( svrFeatureStatus )
; } ;
extern "C" {
svrFeatureStatus
svr_feature_lookup( char const* )
; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_BUILD_ALPHA () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_BUILD_BETA () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_BUILD_RELEASE () ; } ;
struct SVR::CLC::LSL::Diagnostic {
class Assertion;
class Exception;
class ExceptionArea;
class InterfaceCheck;
class InvariantCheck;
class ThrowCompilationUnit;
class ThrowExceptionType;
class ThrowInfo;
class ThrowLineNumber;
class ThrowSource;
class ThrowWithinThrow;
class Throw;
class NoThrow;
class Timer;
static NoThrow noThrow;
};
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_EXCEPTION_COMPILATION_UNIT () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_EXCEPTION_LINE_NUMBER () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_ASSERTION_SOURCE () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_ASSERTION () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_INTERFACE_CHECK () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_INVARIANT_CHECK () ; } ;
class Context {};
class SVR::CLC::LSL::RTTI::Capability {
protected:
typedef SVR::CLC::LSL::RTTI::TypeInfo TypeInfo;
typedef SVR::CLC::LSL::Diagnostic::NoThrow NoThrow;
public:
typedef SVR::CLC::LSL::RTTI::CapabilityIterator Iterator;
typedef SVR::CLC::LSL::RTTI::CapabilityName Name;
class TypedName;
class ExtendedName;
Name const& nameOf() const { return capName; }
TypeInfo const& typeOf() const { return type; }
TypeInfo& typeOf() { return type; }
Capability const* nextOf() const { return next; }
Capability* nextOf() { return next; }
void setNext( Capability& );
protected:
Capability( TypeInfo&, Name const& );
~Capability();
private:
TypeInfo& type;
Name const& capName;
Capability* next;
};
class SVR::CLC::LSL::RTTI::CapabilityName {
protected:
typedef SVR::CLC::LSL::RTTI::Capability Capability;
typedef SVR::CLC::LSL::RTTI::Capability::Name Name;
public:
enum Where
{
before,
near,
here,
chronological,
after
};
virtual Where relativeTo( Name const& ) const;
char const* nameStringOf() const;
protected:
enum Subtype
{
named,
derived,
allocatable,
initializable,
constructible,
castable,
assignable,
destructible,
equatable,
relocatable,
dynamicallyTyped,
callable,
marshalable,
convertibleFrom,
parsableFrom,
renderableAs,
conceptImplementation,
roleImplementation,
language,
encoding,
extended
};
CapabilityName( Subtype );
virtual ~CapabilityName();
public:
static unsigned int const
numberOfSubtypes = extended+1;
private:
Subtype subtype;
static char const* nameString[];
};
class SVR::CLC::LSL::RTTI::Capability::TypedName
: public SVR::CLC::LSL::RTTI::Capability::Name {
protected:
typedef SVR::CLC::LSL::RTTI::TypeInfo TypeInfo;
public:
virtual Where relativeTo( Name const& ) const;
char const* nameStringOf() const;
protected:
TypedName( Subtype, TypeInfo const& );
private:
TypeInfo const& type;
};
class SVR::CLC::LSL::RTTI::Capability::ExtendedName :
public SVR::CLC::LSL::RTTI::Capability::Name {
public:
virtual Where relativeTo( Name const& ) const;
char const* nameStringOf() const;
protected:
ExtendedName( char const* );
private:
char const* nameString;
};
class SVR::CLC::LSL::RTTI::CapabilityIterator {
protected:
typedef SVR::CLC::LSL::RTTI::Capability Capability;
typedef SVR::CLC::LSL::RTTI::Capability::Iterator Iterator;
public:
CapabilityIterator() : current(0) {}
CapabilityIterator( Capability const* p )
: current(p) {}
Iterator& operator ++ ()
{ current = current->nextOf();
return *this; }
operator Capability const* () const
{ return current; }
Capability const& operator * () const
{ return *current; }
Capability const* operator -> () const
{ return current; }
private:
Capability const* current;
};
extern "C" {
typedef struct {
int quot;
int rem;
} div_t;
typedef struct {
long quot;
long rem;
} ldiv_t;
typedef struct {
long long quot;
long long rem;
} lldiv_t;
typedef long wchar_t;
extern unsigned char __ctype[];
extern double atof(const char *);
extern int atoi(const char *);
extern long int atol(const char *);
extern double strtod(const char *, char **);
extern long int strtol(const char *, char **, int);
extern unsigned long int strtoul(const char *, char **, int);
extern int rand(void);
extern void srand(unsigned int);
extern void *calloc(size_t, size_t);
extern void free(void *);
extern void *malloc(size_t);
extern void *realloc(void *, size_t);
extern void abort(void);
extern int atexit(void (*)(void));
extern void exit(int);
extern char *getenv(const char *);
extern int system(const char *);
extern void *bsearch(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *));
extern void qsort(void *, size_t, size_t,
int (*)(const void *, const void *));
extern int abs(int);
extern div_t div(int, int);
extern long int labs(long);
extern ldiv_t ldiv(long, long);
extern int mbtowc(wchar_t *, const char *, size_t);
extern int mblen(const char *, size_t);
extern int wctomb(char *, wchar_t);
extern size_t mbstowcs(wchar_t *, const char *, size_t);
extern size_t wcstombs(char *, const wchar_t *, size_t);
extern double drand48(void);
extern double erand48(unsigned short *);
extern long jrand48(unsigned short *);
extern void lcong48(unsigned short *);
extern long lrand48(void);
extern long mrand48(void);
extern long nrand48(unsigned short *);
extern unsigned short *seed48(unsigned short *);
extern void srand48(long);
extern int putenv(const char *);
extern void setkey(const char *);
extern void swab(const char *, char *, int);
extern long a64l(const char *);
extern int dup2(int, int);
extern char *ecvt(double, int, int *, int *);
extern char *fcvt(double, int, int *, int *);
extern char *qecvt(long double, int, int *, int *);
extern char *qfcvt(long double, int, int *, int *);
extern char *qgcvt(long double, int, char *);
extern char *getcwd(char *, size_t);
extern char *getlogin(void);
extern int getopt(int, char *const *, const char *);
extern int getsubopt(char **, char *const *, char **);
extern char *optarg;
extern int optind, opterr, optopt;
extern char *getpass(const char *);
extern int getpw(uid_t, char *);
extern char *gcvt(double, int, char *);
extern int isatty(int);
extern char *l64a(long);
extern void *memalign(size_t, size_t);
extern char *mktemp(char *);
extern char *realpath(char *, char *);
extern char *ttyname(int);
extern int ttyslot(void);
extern void *valloc(size_t);
extern char *ptsname(int);
extern int grantpt(int);
extern int unlockpt(int);
extern long long atoll(const char *);
extern long long llabs(long long);
extern lldiv_t lldiv(long long, long long);
extern char *lltostr(long long, char *);
extern long long strtoll(const char *, char **, int);
extern unsigned long long strtoull(const char *, char **, int);
extern char *ulltostr(unsigned long long, char *);
}
class SVR::CLC::LSL::RTTI::MetaClassGeneric
{
public:
typedef SVR::CLC::LSL::RTTI::TypeInfo TypeInfo;
typedef SVR::CLC::LSL::RTTI::Capability Capability;
typedef SVR::CLC::LSL::Diagnostic::NoThrow NoThrow;
MetaClassGeneric( TypeInfo& );
virtual ~MetaClassGeneric();
char const* nameOf() const;
char const* codeOf() const;
CapabilityIterator begin( CapabilityName const& ) const;
CapabilityIterator end( CapabilityName const& ) const;
CapabilityIterator end( CapabilityIterator const&,
CapabilityName const& ) const;
Capability const* find( CapabilityName const& ) const;
Capability const* find( CapabilityName const&,
NoThrow const& ) const;
void addCapability( Capability& );
static TypeInfo const* lookup( char const* encoding );
static void dropNames();
operator TypeInfo const& () const
{ return baseInfo; }
operator TypeInfo& ()
{ return baseInfo; }
private:
friend class TypeIDBase;
friend class TypeInfo;
TypeInfo& baseInfo;
Capability* capabilities;
MetaClassGeneric* collisions;
static int const hashTableSize;
static MetaClassGeneric* hashTable[];
mutable char const* fullName;
mutable char const* fullCode;
void install();
void uninstall();
friend class Incapable;
public:
static char const name[];
static char const code[];
static TypeInfo const* templateArguments[];
};
struct SVR::CLC::LSL::RTTI::TypeInfo
{
protected:
typedef SVR::CLC::LSL::RTTI::MetaClassGeneric MetaClassGeneric;
public:
char const* const name;
char const* const code;
TypeInfo const* const* const arguments;
int initializationCount;
MetaClassGeneric* meta;
void (*constructor)( void* );
void initialize( void* );
void finalize();
void check() const;
char const* nameOf() const;
char const* codeOf() const;
MetaClassGeneric const& metaOf() const;
MetaClassGeneric& metaOf();
private:
static int supercount;
friend class MetaClassGeneric;
unsigned hash() const;
static unsigned hash( char const* );
void addToHash( unsigned& ) const;
static void addToHash( unsigned&, char );
char* synthesizeEncoding( char[8] ) const;
bool match( char const* ) const;
bool recursiveMatch( char const*& ) const;
};
template <class T>
class TypeIDInit {
protected:
typedef SVR::CLC::LSL::RTTI::MetaClassGeneric MetaClassGeneric;
typedef SVR::CLC::LSL::RTTI::TypeInfo TypeInfo;
public:
TypeIDInit() { info.initialize(storage); }
~TypeIDInit() { info.finalize(); }
static void initialize() { info.initialize(storage); }
static void finalize() { info.finalize(); }
static void check() { info.check(); }
static TypeInfo info;
static int storage[];
static void metaclassConstructor( void* );
};
template <class T>
class NameInfo : public SVR::CLC::LSL::RTTI::MetaClassGeneric {
public:
NameInfo()
: MetaClassGeneric( TypeIDInit<T>::info ) {}
static char const name[];
static char const code[];
};
template <class T>
class NoNameInfo : public SVR::CLC::LSL::RTTI::MetaClassGeneric {
public:
NoNameInfo()
: MetaClassGeneric( TypeIDInit<T>::info ) {}
};
template <class T>
class TemplateNameInfo : public SVR::CLC::LSL::RTTI::MetaClassGeneric {
public:
TemplateNameInfo( TypeInfo& i )
: MetaClassGeneric( i ) {}
static char const name[];
static char const code[];
};
typedef int ptrdiff_t;
typedef unsigned int wint_t;
class SVR::CLC::LSL::RTTI::Allocatable :
public SVR::CLC::LSL::RTTI::Capability {
public:
static Allocatable const* cast( TypeInfo const* );
static Allocatable const* cast( TypeInfo const*, NoThrow const& );
virtual size_t sizeOf() const = 0;
virtual void* allocate( size_t ) const;
virtual void* allocate() const;
virtual void deallocate( void* ) const;
protected:
Allocatable( TypeInfo& );
private:
typedef Capability::Name CapabilityName;
class Name : public Capability::Name
{
public:
Name() : Capability::Name( allocatable ) {}
};
int site[ sizeof( Name ) / sizeof( int ) ];
};
template <class Type>
class AllocatableClass : public SVR::CLC::LSL::RTTI::Allocatable {
public:
virtual size_t sizeOf() const;
protected:
AllocatableClass()
: Allocatable( TypeIDInit<Type>::info ) {}
};
class SVR::CLC::LSL::RTTI::Initializable :
public SVR::CLC::LSL::RTTI::Capability {
public:
static Initializable const* cast( TypeInfo const* );
static Initializable const* cast( TypeInfo const*, NoThrow const& );
virtual void* initialize( void* ) const = 0;
protected:
Initializable( TypeInfo& );
private:
typedef Capability::Name CapabilityName;
class Name : public Capability::Name
{
public:
Name() : Capability::Name( initializable ) {}
};
int site[ sizeof( Name ) / sizeof( int ) ];
};
class SVR::CLC::LSL::RTTI::NullInitializable :
public SVR::CLC::LSL::RTTI::Initializable {
public:
virtual void* initialize( void* ) const;
protected:
NullInitializable( TypeInfo& );
};
template <class Type>
class NullInitializableClass :
public SVR::CLC::LSL::RTTI::NullInitializable {
protected:
NullInitializableClass()
: NullInitializable( TypeIDInit<Type>::info ) {}
};
class SVR::CLC::LSL::RTTI::ConvertibleFrom
: public SVR::CLC::LSL::RTTI::Capability {
public:
static ConvertibleFrom const*
cast( TypeInfo const*, TypeInfo const* );
static ConvertibleFrom const*
cast( TypeInfo const*,
TypeInfo const*,
NoThrow const& );
virtual void* convert( void*, void const* ) const = 0;
virtual void* convert( void const* ) const;
protected:
ConvertibleFrom( TypeInfo&, TypeInfo const& );
private:
ConvertibleFrom( TypeInfo& );
friend class Copyable;
typedef Capability::Name CapabilityName;
class Name : public Capability::TypedName
{
public:
Name( TypeInfo const& t )
: Capability::TypedName( convertibleFrom, t )
{}
};
int site[ sizeof( Name ) / sizeof( int ) ];
};
class SVR::CLC::LSL::RTTI::Copyable
: public SVR::CLC::LSL::RTTI::ConvertibleFrom
{
public:
static Copyable const* cast( TypeInfo const* );
static Copyable const* cast( TypeInfo const*, NoThrow const& );
virtual void* copy( void*, void const* ) const = 0;
virtual void* convert( void*, void const* ) const;
virtual void* clone( void const* ) const;
protected:
Copyable( TypeInfo& );
private:
};
class SVR::CLC::LSL::RTTI::BitwiseCopyable :
public SVR::CLC::LSL::RTTI::Copyable {
public:
virtual void* copy( void*, void const* ) const;
protected:
BitwiseCopyable( TypeInfo& );
private:
size_t size;
};
template <class Type>
class BitwiseCopyableClass :
public SVR::CLC::LSL::RTTI::BitwiseCopyable {
protected:
BitwiseCopyableClass() : BitwiseCopyable( TypeIDInit<Type>::info ) {}
};
class SVR::CLC::LSL::RTTI::Assignable :
public SVR::CLC::LSL::RTTI::Capability {
public:
static Assignable const* cast( TypeInfo const* );
static Assignable const* cast( TypeInfo const*, NoThrow const& );
static Assignable const* cast( TypeInfo const*, TypeInfo const* );
static Assignable const* cast( TypeInfo const*, TypeInfo const*,
NoThrow const& );
virtual void* assign( void*, void const* ) const = 0;
protected:
Assignable( TypeInfo& );
Assignable( TypeInfo&, TypeInfo const& );
private:
typedef Capability::TypedName CapabilityTypedName;
class Name : public Capability::TypedName
{
public:
Name( TypeInfo const& t ) : Capability::TypedName( assignable, t ) {}
};
int site[ sizeof( Name ) / sizeof( int ) ];
};
class SVR::CLC::LSL::RTTI::BitwiseAssignable :
public SVR::CLC::LSL::RTTI::Assignable {
public:
virtual void* assign( void*, void const* ) const;
protected:
BitwiseAssignable( TypeInfo& );
private:
size_t size;
};
template <class Type>
class BitwiseAssignableClass :
public SVR::CLC::LSL::RTTI::BitwiseAssignable {
protected:
BitwiseAssignableClass() : BitwiseAssignable( TypeIDInit<Type>::info ) {}
};
class SVR::CLC::LSL::RTTI::Destructible :
public SVR::CLC::LSL::RTTI::Capability {
public:
static Destructible const* cast( TypeInfo const* );
static Destructible const* cast( TypeInfo const*, NoThrow const& );
virtual void destruct( void* ) const = 0;
virtual void destroy( void* ) const;
protected:
Destructible( TypeInfo& );
private:
typedef Capability::Name CapabilityName;
class Name : public Capability::Name
{
public:
Name() : Capability::Name( destructible ) {}
};
int site[ sizeof( Name ) / sizeof( int ) ];
};
class SVR::CLC::LSL::RTTI::NullDestructible :
public SVR::CLC::LSL::RTTI::Destructible {
public:
virtual void destruct( void* ) const;
protected:
NullDestructible( TypeInfo& );
};
template <class Type>
class NullDestructibleClass :
public SVR::CLC::LSL::RTTI::NullDestructible {
protected:
NullDestructibleClass() : NullDestructible( TypeIDInit<Type>::info ) {}
};
class SVR::CLC::LSL::RTTI::Equatable :
public SVR::CLC::LSL::RTTI::Capability {
public:
static Equatable const* cast( TypeInfo const* );
static Equatable const* cast( TypeInfo const*, NoThrow const& );
static Equatable const* cast( TypeInfo const*, TypeInfo const* );
static Equatable const* cast( TypeInfo const*, TypeInfo const*,
NoThrow const& );
virtual bool equal( void const*, void const* ) const = 0;
protected:
Equatable( TypeInfo& );
Equatable( TypeInfo&, TypeInfo const& );
private:
typedef Capability::Name CapabilityName;
class Name : public Capability::TypedName
{
public:
Name( TypeInfo const& t ) : Capability::TypedName( equatable, t ) {}
};
int site[ sizeof( Name ) / sizeof( int ) ];
};
class SVR::CLC::LSL::RTTI::BitwiseEquatable :
public SVR::CLC::LSL::RTTI::Equatable {
public:
virtual bool equal( void const*, void const* ) const;
protected:
BitwiseEquatable( TypeInfo& );
private:
size_t size;
};
template <class Type>
class BitwiseEquatableClass :
public SVR::CLC::LSL::RTTI::BitwiseEquatable {
protected:
BitwiseEquatableClass() : BitwiseEquatable( TypeIDInit<Type>::info ) {}
};
template <class T>
class POD :
public AllocatableClass<T>,
public NullInitializableClass<T>,
public BitwiseCopyableClass<T>,
public BitwiseAssignableClass<T>,
public NullDestructibleClass<T>,
public BitwiseEquatableClass<T>
{
};
class MetaClass<int> :
public NameInfo<int>,
public POD<int> {
};
class MetaClass<unsigned> :
public NameInfo<unsigned>,
public POD<unsigned> {
};
class MetaClass<short> :
public NameInfo<short>,
public POD<short> {
};
class MetaClass<unsigned short> :
public NameInfo<unsigned short>,
public POD<unsigned short> {
};
class MetaClass<long> :
public NameInfo<long>,
public POD<long> {
};
class MetaClass<unsigned long> :
public NameInfo<unsigned long>,
public POD<unsigned long> {
};
struct SVR::CLC::STL {
struct Containers;
};
struct SVR::CLC::STL::Containers {
class Linked;
class Chained;
};
template <class T> class List;
template <class T> class Chain;
class SVR::CLC::STL::Containers::Linked
{
public:
Linked();
~Linked();
size_t length() const;
bool isEmpty() const { return head == 0; }
class Iterator;
Iterator begin() const;
Iterator end() const;
protected:
class Element;
Element* detach( Element* current,
Element* previous );
Element* attach( Element* current,
Element* previous );
Element* headOf() const { return head; }
Element* tailOf() const { return tail; }
void clear();
private:
void detachIterators();
void endIterators();
Element* head;
Element* tail;
Iterator* openIterators;
friend class Iterator;
friend class Element;
inline Linked( const Linked& );
inline
Linked& operator = ( const Linked& );
};
class SVR::CLC::STL::Containers::Linked::Element
{
public:
typedef SVR::CLC::STL::Containers::Linked Linked;
virtual void validate( Linked const* = 0 ) const;
protected:
void* operator new ( size_t );
void operator delete ( void*, size_t );
Element() : next(0) {}
~Element();
Element* nextOf() const { return next; }
void clear();
private:
Element* next;
friend class Linked;
friend class Linked::Iterator;
};
class SVR::CLC::STL::Containers::Linked::Iterator
{
public:
~Iterator();
bool operator != ( Iterator const& ) const;
bool operator == ( Iterator const& ) const;
operator bool () const;
protected:
typedef SVR::CLC::STL::Containers::Linked Linked;
typedef SVR::CLC::STL::Containers::Linked::Element Element;
Iterator();
Iterator( Linked*, Element* const& );
Iterator( Iterator const& );
Iterator& operator = ( Iterator const& );
Iterator& operator ++ ();
Iterator operator ++ ( int );
Element* currentElementOf() const;
Element* operator -> () const;
private:
Linked* detach();
void attach( Linked* );
Linked* list;
Iterator* previous;
Iterator* next;
Element* ptr;
Element* const* pPtr;
friend class Linked;
};
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_LINKED_CHECK () ; } ;
extern "C" { svrFeatureStatus svr_feature_lookup_SVR_LINKED_INHIBIT_REUSE () ; } ;
class SVR::CLC::STL::Containers::Chained :
public SVR::CLC::STL::Containers::Linked
{
public:
protected:
class Element;
Element* detach( Element* current );
Element* detach( Element* current,
Element* previous );
Element* attach( Element* current,
Element* previous );
Element* headOf() const;
Element* tailOf() const { (Element*) Linked::tailOf(); }
};
inline SVR::CLC::STL::Containers::Chained::Element*
SVR::CLC::STL::Containers::Chained::headOf() const
{
(Element*) Linked::headOf();
}
class SVR::CLC::STL::Containers::Chained::Element :
public SVR::CLC::STL::Containers::Linked::Element
{
public:
virtual void validate( Linked const* = 0 ) const;
protected:
typedef SVR::CLC::STL::Containers::Chained Chained;
Element() : previous(0) {}
~Element();
void* operator new ( size_t );
void operator delete ( void*, size_t );
Element* previousOf() const { return previous; }
Element* nextOf() const {
return (Element*) Linked::Element::nextOf();
}
void clear();
private:
Element* previous;
friend class Chained;
};
template <class T> class ChainIterator;
template <class T> class ChainElement;
template <class T>
class Chain : public SVR::CLC::STL::Containers::Chained
{
public:
Chain() {}
Chain( const Chain<T>& );
~Chain();
Chain& operator = ( const Chain<T>& );
typedef ChainElement<T> Element;
Element* insert( const T& );
void clear();
bool remove( const T& );
void removeElement( Element* );
bool removeFirst();
T& first() const;
T& last() const;
typedef ChainIterator<T> Iterator;
Iterator begin() const;
Iterator end() const;
protected:
Element* detach( Element* current );
Element* detach( Element* current,
Element* previous );
Element* attach( Element* current,
Element* previous );
Element* headOf() const;
Element* tailOf() const;
};
template <class T>
class ChainElement : public SVR::CLC::STL::Containers::Chained::Element
{
public:
operator T const& () const { return elem; }
protected:
ChainElement( const T& e ) : elem(e) {}
ChainElement<T>* previousOf() const;
ChainElement<T>* nextOf() const;
private:
T elem;
friend class Chain<T>;
friend class ChainIterator<T>;
};
#if 1
template <class T>
inline
ChainElement<T>*
Chain<T>::headOf() const
{
return (ChainElement<T>*) Chained::headOf();
}
#endif
extern "C" int printf( char const*, ... );
template <class T>
void
Chain<T>::clear()
{
Element* ptr = headOf();
printf( "0x%08x\n", ptr );
Chained::clear();
}
template class Chain<int> ;
More information about the Gcc-bugs
mailing list