tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Function pointers declared in a particular way result in


From: Jonathan Newman
Subject: [Tinycc-devel] Function pointers declared in a particular way result in a miscompilation
Date: Sat, 29 Dec 2018 04:30:26 +0000

Hi,
This seems to be the issue causing SQLite compilation to fail (or at least part of it/related to it).

When a function pointer is declared in a particular way, it seems that __stdcall (and presumably other attributes?) are ignored. As a result, TCC thinks the function is caller-cleanup when it is not, and the stack gets "cleaned" twice.

See the full test case attached. As a quick summary,

This works:
((int __stdcall (*)(int, int, int))some_stdcall_func) (2, 0, 0);

And so does this:
((int(*__stdcall)(int, int, int))some_stdcall_func) (3, 0, 0);

But this fails:
((int(__stdcall*)(int, int, int))some_stdcall_func) (4, 0, 0);

This is mostly relevant on 32-bit Windows (where the stdcall convention is common).

Attachment: minimal.c
Description: Text document


reply via email to

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