[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] "function pointer expected" error in valid ternary se
From: |
Dave Dodge |
Subject: |
Re: [Tinycc-devel] "function pointer expected" error in valid ternary sequence |
Date: |
Sat, 19 Mar 2005 07:35:41 -0500 |
User-agent: |
Mutt/1.4.2i |
On Thu, Mar 17, 2005 at 05:32:08PM +0000, Jason Davies wrote:
> int i = (1 == 0 ? foo : bar)();
Known bug. Try this patch I posted in November...
-Dave Dodge
The problem is that tcc doesn't have any code to recognize function
pointers within a conditional expression, so it defaults to treating
them as integers. The resulting expression then has integer type,
which of course isn't valid for a function call. Here's a quick (but
somewhat incomplete) workaround.
--- tcc-0.9.22/tcc.c 2004-11-08 15:47:16.000000000 -0500
+++ tcc-0.9.22-fixed/tcc.c 2004-11-11 02:55:54.000000000 -0500
@@ -7598,6 +7598,9 @@
} else if (bt1 == VT_PTR || bt2 == VT_PTR) {
/* XXX: test pointer compatibility */
type = type1;
+ } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) {
+ /* XXX: test function pointer compatibility */
+ type = type1;
} else if (bt1 == VT_STRUCT || bt2 == VT_STRUCT) {
/* XXX: test structure compatibility */
type = type1;