Opened 3 years ago

Closed 2 years ago

#9726 closed bug (fixed)

Linker.c uses of swprintf() fail to compile on gcc 4.8.3

Reported by: gintas Owned by: gintas
Priority: normal Milestone:
Component: Runtime System Version: 7.9
Keywords: Cc: simonmar
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D372
Wiki Page:

Description

swprintf has different signatures in mingw32, where it does not include the buffer size, and in mingw-w64, where it does. That of course breaks the code as mingw-w64 treats the pointer to the format string as a size_t. Bummer:

C:/.../inplace/mingw/i686-w64-mingw32/include/swprintf.inl:30:5: note: expected 'size_t' but argument is of type 'short unsigned int *'

int swprintf (wchar_t *stream, size_t count, const wchar_t *format, ...)

rts\Linker.c:1986:12:

warning: passing argument 2 of 'swprintf' makes integer from pointer without a cast [enabled by default]

swprintf(buf, L"lib%s.DLL", dll_name);

I have a fix pending to use snwprintf instead.

Change History (4)

comment:1 Changed 3 years ago by awson

#define _CRT_NON_CONFORMING_SWPRINTFS also solves the problem.

comment:2 Changed 3 years ago by gintas

Differential Rev(s): Phab:D372

comment:3 Changed 2 years ago by Austin Seipp <austin@…>

In 5ce1266a7d323fd4fe4262f07be908d65e5b5b43/ghc:

Use snwprintf instead of swprintf in rts/Linker.c.

Summary:
swprintf has different signatures in mingw32, where it does not include the
buffer size, and in mingw-w64, where it does. That of course breaks the code
as mingw-w64 treats the pointer to the format string as a size_t.

snwprintf is available in both environments and is consistent, so use that
instead.

Reviewers: simonmar, austin

Reviewed By: austin

Subscribers: #ghc_windows_task_force, thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D372

GHC Trac Issues: #9726

comment:4 Changed 2 years ago by gintas

Resolution: fixed
Status: newclosed

Thanks.

I slightly prefer using swnprintf() to the #define since it's safer and generally seems cleaner...

Note: See TracTickets for help on using tickets.