Inconsistent snprintf format specification parsing
Bug #221979 reported by
Dmitry Pankratov
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mingw32 (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: mingw32-runtime
OS: Ubuntu 8.04/AMD64.
Package: 3.13-1
Description:
The snprintf library function incorrectly parses the "%lu" format specifier as "unsigned long long" instead of "unsigned long" resulting in incorrect value formatting.
Example:
#include <stdio.h>
int main() {
char buf[256];
snprintf(buf, 256, "%lu", (size_t)12345678);
printf(buf);
return 0;
}
Prints:
9151369040453460302
Instead of:
12345678
Other functions like printf and sprintf do work fine.
Native Linux GCC compiler version 4.2.3 produces correct code in both 32 and 64 mode.
When replacing (size_t) with (unsigned long long) the above code works fine also in mingw32.
To post a comment you must log in.
Looks like this problem is fixed in the mingw-runtime 3.14. Is it possible to update Ubuntu package with the latest upstream version?