bugTiny C Compiler - Bugs: bug #65926, swprintf does not work as expected.

 
 

bug #65926: swprintf does not work as expected.

Submitter:  Marek Knápek <marekknapek>
Submitted:  Fri 28 Jun 2024 08:27:55 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 28 Jun 2024 08:27:55 AM UTC, original submission:  


Hi, I have problem using the `swprintf` C standard library function with TCC on the Windows operating system. For example, `test.c`.

```
#include <wchar.h>
int main(void)
{
int r;
wchar_t buf[32];
r = swprintf(&buf[0], 32, L"%d\n", 42);
return r;
}
```

Command line: `tcc test.c`.
Output: `test.c:6: warning: assignment makes pointer from integer without a cast`.
When running the compiled program, it crashes.

The problem is taht according the C standard the `swprintf` function has the following signature
`int swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, ...);`, but the TCC
compiler think that the signature is `_CRTIMP int __cdecl swprintf(wchar_t*, const wchar_t*, ...);`.
So, there is mismatch and the compiled program crashes at run time.


Marek Knápek <marekknapek>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by marekknapek (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4b4b.
    Corresponding source code