[Bug c++/44916] Incorrect function overloading with static_cast

2010-07-18 Thread james dot dennett at gmail dot com


--- Comment #1 from james dot dennett at gmail dot com  2010-07-18 21:37 
---
Thanks to Ian for reporting this for me (my buganizer account wasn't well at
the time).

This appears to duplicate bug 39415.

I have a hacky fix for this, adding a conversion to the correct target type
after the conversion used by the current code, included here for reference:

$ svn diff gcc/cp/typeck.c
Index: gcc/cp/typeck.c
===
--- gcc/cp/typeck.c (revision 157950)
+++ gcc/cp/typeck.c (working copy)
@@ -5743,7 +5743,14 @@
  base = lookup_base (TREE_TYPE (type), TREE_TYPE (intype),
 c_cast_p ? ba_unique : ba_check,
 NULL);
-  return build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false);
+  return build_static_cast_1 (type,
+  build_base_path (MINUS_EXPR,
+   expr,
+   base,
+   /*nonnull=*/false),
+  c_cast_p,
+  valid_p,
+  complain);
}

  if ((TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))


-- 

james dot dennett at gmail dot com changed:

   What|Removed |Added

 CC|        |james dot dennett at gmail
   |        |dot com


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



[Bug c++/39415] static_cast used as downcast can silently lose const

2010-07-18 Thread james dot dennett at gmail dot com


--- Comment #2 from james dot dennett at gmail dot com  2010-07-18 21:39 
---
44916 is a duplicate of this bug (and includes a hacky fix, but no automated
regression test).


-- 


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