[c++ bug] operator name revamp

Nathan Sidwell nathan@codesourcery.com
Tue May 30 08:53:00 GMT 2000


Mark,
Unfortunately your patch to abstract the names of overloaded operators
breaks the following
	struct A {
	  bool operator== (A const &);
	  operator bool () const;
	  operator int * () const;
	};

	bool foo (A &a1, A &a2)
	{
	  return a1 == a2;
    	}
nathan@uha:9>./cc1plus current/nathan216.C 
current/nathan216.C: In function `bool foo (A &, A &)':
current/nathan216.C:10: Internal compiler error.

Program received signal SIGSEGV, Segmentation fault.
0x8228b58 in joust (cand1=0x401287e0, cand2=0x40128460, warn=0) at call.c:5131
5131          if (DECL_OVERLOADED_OPERATOR_P (cand1->fn) == COND_EXPR)
(gdb) back
#0  0x8228b58 in joust (cand1=0x401287e0, cand2=0x40128460, warn=0) at call.c:5131
#1  0x822906a in tourney (candidates=0x401287e0) at call.c:5197
#2  0x8224f50 in build_new_op (code=EQ_EXPR, flags=3, arg1=0x40125ea0, arg2=0x40125ec0, arg3=0x0) at call.c:3346
#3  0x829c518 in build_x_binary_op (code=EQ_EXPR, arg1=0x40125ea0, arg2=0x40125ec0) at typeck.c:3249
#4  0x8288672 in yyparse () at parse.y:1316
#5  0x804c383 in compile_file (name=0x40117e80 "current/nathan216.C") at toplev.c:2288
#6  0x8050271 in main (argc=2, argv=0xbffff6b4) at toplev.c:4702
(gdb) print cand1->fn->common.code
$1 = IDENTIFIER_NODE

If you look at the conditional above this,
  /* If the built-in candidates are the same, arbitrarily pick one.  */
  if (! winner && cand1->fn == cand2->fn
      && TREE_CODE (cand1->fn) == IDENTIFIER_NODE)
you'll see that cand1->fn _must_ be an IDENTIFIER_NODE. Oh dear.

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org


More information about the Gcc-bugs mailing list