[Top][All Lists]

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

Re: [Tinycc-devel] Mis-parse in some situations involving a function poi

From: Jonathan Newman
Subject: Re: [Tinycc-devel] Mis-parse in some situations involving a function pointer with attributes (breaks SQLite build)
Date: Wed, 25 Jul 2018 13:28:06 +0100

It may be specific to 32-bit Windows with regards to sqlite, although I'm not sure why my example would work correctly with a Linux build. Tested with 0.9.27 and latest mob. My example fails with both -m32 and -m64. sqlite does build with -m64, because WINAPI expands to nothing, and there are therefore no attributes to parse.

The macro osMultiByteToWideChar defined at sqlite-amalgamation-3240000/sqlite3.c:L40571 contains the offending cast. The actual errors reported by TCC are on different lines ("cannot use pointers here" on L41385 and some integer-from-pointer warnings).

Also, I took a closer look at TODO and found that this might be a known issue:
>- handle void (__attribute__() *ptr)()

On Wed, 25 Jul 2018 at 11:56, Ben Bacarisse <address@hidden> wrote:
Jonathan Newman <address@hidden> writes:

> I happened across this issue while trying to build SQLite. I've attached a test case. To
> summarise:
> * Start off with a function pointer, correctly assigned to a function that has attributes,
> but cast to a void* (or indeed anything except the correct function pointer type)
> * Cast this void* to the correct function pointer type, and call it
> * Observe that one cast+call syntax works correctly, and another results in a
> misparse:
> * tcc thinks the type of the entire _expression_ (cast+call) is a pointer, instead of the
> correct return type of the called function (here, an integer).
> * gcc happily accepts both syntaxes
> * This breaks compilation of the sqlite.c amalgamation, at least on 32-bit windows
> The failing syntax is perhaps unusual. It might actually be deliberately unsupported,
> but in that case:
> * sqlite will not build without modifications
> * tcc should stop here with an error instead of erroneously treating the _expression_ as a
> pointer
> Hope someone can take a look at this. It can be worked around with some
> modifications to sqlite.

What versions are you using (of both tcc and sqlite.c)?  With
sqlite-324000 and tcc version 0.9.27 (x86_64 Linux) I get no errors, and
your test example also compiles (and runs) error-free.

Can you cite the part of the sqlite source that causes the problem?
I could not find any similar syntax, but then "grep"ing for syntax often
does not work.

Converting between object pointers and function pointers is not
permitted in standard C, so a test example without that would be better.
Obviously I can't investigate to see if that's an important part of the
bug because I can't see the issue to start with!


reply via email to

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