在 2019/9/5 7:12, Jacek Caban 写道: > > I'm fine with this patch, but not so much about the fortify patch. > Earlier this year we discussed inlines and if I remember right (sorry, I > can't fine it now, maybe it was on IRC), the conclusion was to try to > move toward static inline everywhere. Commit > 6988d73a95fbbd97a0bdbb517008cf18f4eb5f02 was a test to see if anything > breaks. It seems fine so far, so I'd suggest to open code static inline > for fortify wrappers instead of introducing a few new inline override > macros. > > There is something worse: As these wrappers uses `__builtin_va_arg_pack()` they MUST always be emitted inline, not just be declared inline. If inline is not possible, the inline definition cannot be used, which is exactly the `__gnu_inline__` behavior.
Yeah, the bad news is that we now have a bug: ``` #define __USE_MINGW_ANSI_STDIO 1 #include <stdio.h> int main(void) { printf("%lld\n", (long long)sprintf); } ``` ``` E:\Desktop>gcc test.c In file included from test.c:2: C:/MinGW/MSYS2/mingw64/x86_64-w64-mingw32/include/stdio.h: In function 'sprintf': C:/MinGW/MSYS2/mingw64/x86_64-w64-mingw32/include/stdio.h:371:10: error: invalid use of '__builtin_va_arg_pack ()' 371 | return __mingw_sprintf( __stream, __format, __builtin_va_arg_pack() ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` This doesn't happen if `__USE_MINGW_ANSI_STDIO` was not defined, where the other definition would be used, which is specified as `__mingw_bos_extern_ovr` rather than `__mingw_va_arg_pack_ovr`. The former expands to `extern __inline__ __attribute__((__gnu_inline__))` while the latter expands to `static __inline__`. When the address of the function is taken, GCC has to emit a body of the latter, which contains `__builtin_va_arg_pack()`, which causes an error. `snprintf()` always suffers from this issue because both definitions are specified as `__mingw_va_arg_pack_ovr`. I think that `__mingw_va_arg_pack_ovr` should be changed to `extern __inline__`. It is identical to `__mingw_bos_extern_ovr` thereafter. -- Best regards, LH_Mouse
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public