From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Martin v. Loewis" To: selez@barad.tme.mcst.ru Cc: egcs-bugs@cygnus.com Subject: Re: Bug report Date: Wed, 03 Mar 1999 09:29:00 -0000 Message-id: <199903031725.SAA32131@mira.isdn.cs.tu-berlin.de> In-reply-to: < Pine.LNX.4.10.9903021526420.31990-300000@barad.tme.mcst.ru >(message from Igor Seleznev on Tue, 2 Mar 1999 15:37:01 +0300 (MSK)) References: X-SW-Source: 1999-03/msg00130.html List-Id: > I think I have found a compiler bug, look in attachment for details. > There are two C++ source files - 'test.cc' and 'test_new.cc' I couldn't find any difference in the files you sent; your description was clear enough to let me understand your problem. > Seems that when I am calling an operator with 'const' modifier and > there are one more operator exist without any 'const', then it will > call last one instead of what I am wishing to be called. Just so we are sure what we are talking about, I include the relevant part of your code: class a { public: operator bool() const { printf( "bool operator\n" ); return true; } operator int() { printf( "int operator\n" ); return 1; } }; int main() { a a1; bool b = a1; } In this case, operator int() is called, instead of operator bool()const. This might be confusing, but is correct: Both operators can be used to initialize b, because there is a standard conversion from int to bool. So which one is better? This is decided by overload resolution. We look at the arguments: there is one argument, of type 'class a*'. For operator int, we can directly call the conversion function. For operator bool, we have to convert 'class a*' to 'const class a*' (qualification conversion). So the function with less conversion is called, which is operator int. If you want the conversion work as expected, you also have to provide an "operator bool();". Both this operator and the operator int() are identical in terms of argument conversion, but the bool operator gives the better result. Hope this helps, Martin >>From ghazi@caip.rutgers.edu Wed Mar 03 09:40:00 1999 From: "Kaveh R. Ghazi" To: zack@rabi.columbia.edu Cc: egcs-bugs@egcs.cygnus.com Subject: Re: Bug in cpp macro varargs extension Date: Wed, 03 Mar 1999 09:40:00 -0000 Message-id: <199903031739.MAA07709@caip.rutgers.edu> X-SW-Source: 1999-03/msg00131.html Content-length: 1356 > From: Zack Weinberg > > On Tue, 2 Mar 1999 13:19:50 -0500 (EST), "Kaveh R. Ghazi" wrote: > > Does anyone use gcc's macro varargs extension? Is is > >considered usable? > > > > I'm having several problems getting correct expansions. I think > >it boils down to this test case: > > > > > #define error1(msg, args...) printf(msg, "foo", ## args) > > > #define error2(msg, args...) printf("foo", msg, ## args) > [...] > > ## args, where args is an empty rest argument, deletes the `preceding > sequence of nonwhitespace characters', not the preceding token. You > want > > #define error1(msg, args...) printf(msg, "foo" , ## args) > > Yes this is ugly. It's done this way since cpp doesn't know what the > "preceding token" is. cpp.info says that "we" may consider changing > it to the preceding token in the future. Presumably this would > involve a token-based macro expander. I've been thinking about that > idly. The benefits are not clear, besides making it easier to > implement C89 Amendment 1 digraphs. > > cpplib behaves identically. > > zw Urg, my fault. I didn't catch this when I read the docs on macro varargs. Thanks for your help. --Kaveh -- Kaveh R. Ghazi Engagement Manager / Project Services ghazi@caip.rutgers.edu Qwest Internet Solutions >>From Dirk.Duellmann@cern.ch Wed Mar 03 09:45:00 1999 From: Dirk Duellmann To: egcs-bugs@egcs.cygnus.com Subject: Invalid code generated from release 1.1.1 and snapshot 19990228 Date: Wed, 03 Mar 1999 09:45:00 -0000 Message-id: <36DD7537.594D2CA7@cern.ch> X-SW-Source: 1999-03/msg00132.html Content-length: 1473 Dear egcs developers, the following program fails during linking step with: [iron] ~/src/egcs-bugs % /usr/egcs/snapshot/bin/g++ -o exp exp.cpp /tmp/ccRFaaaa.o: In function `main': /tmp/ccRFaaaa.o(.text+0x31): undefined reference to `point::setValues(int, int, float const (*)[2])' collect2: ld returned 1 exit status The problems seems to be that the code generated for main tries to pull in point::setValues(int, int, float const (*)[2]) instead of point::setValues(int, int, float const (*)[3]) . Cheers and thanks for the nice compiler ! Dirk // exp.cpp class point { public: void setValues (int , int , float const [][3] ) {}; }; int main() { const float pts[][3] = {{-4.5,-2.0, 8.0}, {-2.0, 1.0, 8.0}, { 2.0,-3.0, 6.0}, { 5.0,-1.0, 8.0}, {-3.0, 3.0, 4.0}, { 0.0,-1.0, 4.0}, { 1.0,-1.0, 4.0}, { 3.0, 2.0, 4.0}, {-5.0,-2.0,-2.0}, {-2.0,-4.0,-2.0}, { 2.0,-1.0,-2.0}, { 5.0, 0.0,-2.0}, {-4.5, 2.0,-6.0}, {-2.0,-4.0,-5.0}, { 2.0, 3.0,-5.0}, { 4.5, -2.0, -6.0}}; point mypoint ; mypoint.setValues(0,16, pts); exit(0); } -- ------------------------------------------------------------ Dirk Duellmann Tel : +41 22 767 4937 IT Division 513 1-007 Fax : +41 22 767 8630 CERN Mail: Dirk.Duellmann@cern.ch CH-1211 Geneva 23 WWW: http://home.cern.ch/~dirkd >>From john@Calva.COM Wed Mar 03 09:46:00 1999 From: "John Hughes" To: Cc: Subject: egcs-1.1.1: fixed or forbidden register 3 (bx) was spilled for class GENERAL_REGS. Date: Wed, 03 Mar 1999 09:46:00 -0000 Message-id: <005801be659d$c25d0720$0e0110ac@britannic.AtlanTech.COM> X-SW-Source: 1999-03/msg00133.html Content-length: 5309 When compiling "sfdcunion" from sfio-1998 I get this error. There is no "asm" in the function. The compilation command is: gcc -v -O -fomit-frame-pointer -fpic egcs-bug.c The source (stripped down gcc -E output) of the function is appended to this message. The compiler output is: Reading specs from /u/local/lib/gcc-lib/i386-pc-sysv4.2uw2.1.3/egcs-2.91.60/specs gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release) /u/local/lib/gcc-lib/i386-pc-sysv4.2uw2.1.3/egcs-2.91.60/cpp -lang-c -v -und ef -D__GNUC__=2 -D__GNUC_MINOR__=91 -Di386 -Dunix -D__svr4__ -D__i386__ -D__ unix__ -D__svr4__ -D__i386 -D__unix -Asystem(unix) -Asystem(svr4) -Acpu(i386 ) -Amachine(i386) -D__OPTIMIZE__ egc-bug.c /var/tmp/ccuTsq5p.i GNU CPP version egcs-2.91.60 19981201 (egcs-1.1.1 release) (i386 System V Release 4) #include "..." search starts here: #include <...> search starts here: /u/local/include /u/local/i386-pc-sysv4.2uw2.1.3/include /u/local/lib/gcc-lib/i386-pc-sysv4.2uw2.1.3/egcs-2.91.60/include /usr/include End of search list. /u/local/lib/gcc-lib/i386-pc-sysv4.2uw2.1.3/egcs-2.91.60/cc1 /var/tmp/ccuTsq5p.i -quiet -dumpbase egc-bug.c -O -version -fomit-frame-pointer -fpic -o /var/tmp/ccUX4vyF.s GNU C version egcs-2.91.60 19981201 (egcs-1.1.1 release) (i386-pc-sysv4.2uw2.1.3) compiled by GNU C version egcs-2.91.60 19981201 (egcs-1.1.1 release). egcs-bug.c: In function `unseek': egcs-bug.c:159: fixed or forbidden register 3 (bx) was spilled for class GENERAL_REGS. This may be due to a compiler bug or to impossible asm statements or clauses. -- John Hughes , CalvaEDI SA. Tel: +33-1-4313-3131 66 rue du Moulin de la Pointe, Fax: +33-1-4313-3139 75013 PARIS. typedef unsigned int size_t; typedef unsigned char uchar_t; typedef unsigned short ushort_t; typedef unsigned int uint_t; typedef unsigned long ulong_t; typedef int ssize_t; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; typedef unsigned char u_char; struct timeval; typedef char *__gnuc_va_list; void va_end (__gnuc_va_list); typedef __gnuc_va_list va_list; typedef struct _sfio_s Sfio_t; typedef struct _sfdisc_s Sfdisc_t; typedef ssize_t (*Sfread_f) (Sfio_t*, void *, size_t, Sfdisc_t*) ; typedef ssize_t (*Sfwrite_f) (Sfio_t*, const void *, size_t, Sfdisc_t*) ; typedef long long (*Sfseek_f) (Sfio_t*, long long , int, Sfdisc_t*) ; typedef int (*Sfexcept_f) (Sfio_t*, int, void *, Sfdisc_t*) ; struct _sfdisc_s { Sfread_f readf; Sfwrite_f writef; Sfseek_f seekf; Sfexcept_f exceptf; Sfdisc_t* disc; }; struct _sfio_s { unsigned char* next; unsigned char* endw; unsigned char* endr; unsigned char* endb; Sfio_t* push; unsigned short flags; short file; unsigned char* data; ssize_t size; ssize_t val; long long extent; long long here; unsigned char getr; unsigned char tiny[1]; unsigned short bits; unsigned int mode; struct _sfdisc_s* disc; struct _sfpool_s* pool; void * noop; }; typedef struct _sffmt_s Sffmt_t; typedef int (*Sffmtext_f) (Sfio_t*, void *, Sffmt_t*) ; typedef int (*Sffmtevent_f) (Sfio_t*, int, void *, Sffmt_t*) ; struct _sffmt_s { long version; Sffmtext_f extf; Sffmtevent_f eventf; char* form; va_list args; int fmt; ssize_t size; int flags; int width; int precis; int base; char* t_str; ssize_t n_str; void * noop; }; extern ssize_t _Sfi; typedef struct _sfpool_s Sfpool_t; struct _sfpool_s { Sfpool_t* next; int mode; int s_sf; int n_sf; Sfio_t** sf; Sfio_t* array[3]; }; typedef struct _sfrsrv_s Sfrsrv_t; struct _sfrsrv_s { Sfrsrv_t* next; Sfio_t* sf; ssize_t slen; ssize_t size; unsigned char data[1]; }; typedef struct _fmt_s Fmt_t; typedef struct _fmtpos_s Fmtpos_t; typedef union { int i, *ip; long l, *lp; short h, *hp; unsigned int ui; unsigned long ul; ushort uh; long long ll, *llp; unsigned long long lu; long double ld; double d; float f; char c, *s, **sp; void *vp; Sffmt_t *ft; } Argv_t; struct _fmt_s { char* form; va_list args; char* oform; va_list oargs; int argn; Fmtpos_t* fp; Sffmt_t* ft; Sffmtevent_f eventf; Fmt_t* next; }; struct _fmtpos_s { Sffmt_t ft; Argv_t argv; int fmt; int need[5 ]; }; typedef struct _file_s { Sfio_t* f; long long lower; } File_t; typedef struct _union_s { Sfdisc_t disc; short type; short c; short n; long long here; File_t f[1]; } Union_t; static long long unseek(Sfio_t* f, long long addr, int type, Sfdisc_t* disc) { register Union_t* un; register int i; register long long extent, s; un = (Union_t*)disc; if(un->type& 1 ) return -1L; if(type == 2) { extent = 0; for(i = 0; i < un->n; ++i) extent += (sfsize(un->f[i].f) - un->f[i].lower); addr += extent; } else if(type == 1) addr += un->here; if(addr < 0) return -1; extent = 0; for(i = 0; i < un->n-1; ++i) { s = sfsize(un->f[i].f) - un->f[i].lower; if(addr < extent + s) break; extent += s; } s = (addr-extent) + un->f[i].lower; if(sfseek(un->f[i].f,s,0) != s) return -1; un->c = i; un->here = addr; for(i += 1; i < un->n; ++i) sfseek(un->f[i].f,un->f[i].lower,0); return addr; } ---------------------------------E O F------------------------------------------