tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] patch for cannot cast 'const struct foo' to 'struct foo'


From: Brian Gough
Subject: [Tinycc-devel] patch for cannot cast 'const struct foo' to 'struct foo'
Date: Mon, 31 May 2004 15:18:00 +0100

Hello,
I have made a patch to tcc-0.9.20 for the bug I reported last year,
regarding cannot cast 'const struct foo' to 'struct foo'.

I modified is_compatible_types() to allow for the case where the
source type is const or volatile.

With this patch I was able to compile all of the GNU Scientific
Library.

-- 
Brian Gough

Network Theory Ltd,
Publishing Free Software Manuals --- http://www.network-theory.co.uk/

$ tcc test.c 
test.c:8: cannot cast 'const struct foo' to 'struct foo'
$ tcc -v
tcc version 0.9.20

--test.c--------------------------------------------------------------
struct foo {
  double a[2];
};

void 
init (struct foo * data) {
  const struct foo base = {{1.0, 0.0}};
  *data = base;
  return;
}

int
main (void)
{
  struct foo x;
  init(&x);
  return 0;
}

----------------------------------------------------------------------
RCS file: tcc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- tcc.c       2004/05/29 12:42:45     1.1
+++ tcc.c       2004/05/31 13:54:48     1.2
@@ -5624,10 +5624,12 @@
 {
     int bt1, t1, t2;
 
+    /* type1 is destination, type2 is source */
+
     t1 = type1->t & VT_TYPE;
     t2 = type2->t & VT_TYPE;
     /* XXX: bitfields ? */
-    if (t1 != t2)
+    if (t1 != t2 && t1 != (t2 & (~(VT_CONSTANT | VT_VOLATILE))))
         return 0;
     /* test more complicated cases */
     bt1 = t1 & VT_BTYPE;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]