tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] bug: function pointers are broken


From: Dave Dodge
Subject: Re: [Tinycc-devel] bug: function pointers are broken
Date: Mon, 13 Dec 2004 17:27:45 -0500
User-agent: Mutt/1.4.2i

On Mon, Dec 13, 2004 at 07:08:48AM +0100, Lukas Mai wrote:
> bug2.c:
> int main(void) {
>    (1 ? main : main)();
> }

> bug3.c:
> int main(void) {
>    int (*x)(void) = 1 ? main : main;
>    x();
>    /* attempted workaround for bug2 */
> }

FYI here's a patch I posted last month to make function pointers work
in conditional expressions.  Note that conditional expression support
in 0.9.22 is incomplete and doesn't bother to check that the pointers
are actually compatible.

                                                  -Dave Dodge

--- 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;




reply via email to

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