This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17805] too liberal operator lookup


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-09-29 14:28 -------
The patch:

http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00453.html

is basically OK.  

However, please make the folloing changes before check-in:

+	      && (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (arg1)),
+			       TYPE_MAIN_VARIANT (parmtype))

Use same_type_ignoring_top_level_qualifiers_p.

+		  || (TREE_CODE (parmtype) == REFERENCE_TYPE
+		      && reference_related_p (TREE_TYPE (arg1),
+					      TREE_TYPE (parmtype)))))

That's silly. :-)  Two types are reference-related only if they are cv-qualified
variants of one-another, or class types derived from one-another.  The whole
point is that these aren't class types, so you want
same_type_ignoring_top_level_qualifiers_p again.  So, you really want something
like:

  if (TREE_CODE (parmtype) == REFERENCE_TYPE)
    parmtype = TREE_TYPE (parmtype);
  if (s_t_i_t_l_q_p (TREE_TYPE (arg1), parmtype))
    ...

Also, please code this using a loop:

  for (i = 0; i < 2; ++i) {
    if (i == 1 && !arg2)
      break;
    ...
  }

so that it is obvious that you were using the same tests on both arguments.

OK with those changes.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17805


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]