On 8/22/2012 02:35, Greg Peele wrote:
> 
> Hi all,
> Did MinGW-w64 GCC change behavior at some point regarding printf and long 
> long?   My understanding is that you should use the Microsoft non-standard 
> specifiers %I64d and %I64u and my GCC 4.5.1 is fine with it, but I get the 
> following warning because of that in GCC 4.7.1 (rubenvb's build):
> F:/workspace/ACSL/ToString.h:628:9: warning: format '%u' expects argument of 
> type 'unsigned int', but argument 3 has type 'long long unsigned int' 
> [-Wformat]
> for the following code
>     template <size_t L>    inline void printToBuffer(unsigned long long 
> value, char (&buffer)[L])    {#ifdef WIN32        std::sprintf(buffer, 
> "%I64u", value);#else        std::sprintf(buffer, "%llu", value);#endif    }
> 
> If this is a spurious warning, I can use -Wno-format to suppress it (this 
> inline method gets included a LOT of places in my code) but of course that 
> loses the ability of using that warning as a legitimate way to warn about 
> printf bugs.
> ... also, copying that code, I realized that it's a buffer overrun risk.  
> Yikes. 
> Gregory Peele Jr.
>                                         

Use %lld, as C++ header will force gnu printf semantics to fix std
stream problems with 64bit data types.


Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to