This is the mail archive of the gcc-patches@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]

Re: getting closer


On Wed, Dec 09, 1998 at 11:17:55PM -0800, Chris Toshok wrote:
> > Since the tree is not yet buildable, would you preprocess that for me?
> > I don't see a problem with a simplified test case:
> > 
> > struct JavaObject;
> > typedef JavaObject *obj;
> > 
> > void foo(obj);
> > 
> > void bar(void *x)
> > {
> >   foo(reinterpret_cast<obj>(x));
> > }
> 
> yeah, you're example works.  i guess the problem might be that the
> original type of x in the ef code is void (*)():
[...]
> ../../LocalIncludes/Address.h:127: reinterpret_cast from `void (*)()' to
> `JavaObject *'

There is a typo, but fixing it yields a surprise:

z.cc:8: ANSI C++ forbids casting between pointers to functions and objects

I'm no C++ language lawyer, though, so I'll take it on face value.


r~



	* typeck.c (build_reinterpret_cast): Fix typo in duplicated test.


Index: typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.128
diff -u -p -r1.128 typeck.c
--- typeck.c	1998/12/07 12:27:47	1.128
+++ typeck.c	1998/12/10 08:19:24
@@ -5473,7 +5473,7 @@ build_reinterpret_cast (type, expr)
       return fold (build1 (NOP_EXPR, type, expr));
     }
   else if ((TYPE_PTRFN_P (type) && TYPE_PTROBV_P (intype))
-	   || (TYPE_PTRFN_P (type) && TYPE_PTROBV_P (intype)))
+	   || (TYPE_PTRFN_P (intype) && TYPE_PTROBV_P (type)))
     {
       pedwarn ("ANSI C++ forbids casting between pointers to functions and objects");
       if (TREE_READONLY_DECL_P (expr))



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