Sun 17 Feb 2013 01:35:46 PM UTC, comment #12:
For the record:
> But I thought that sizeof(long) were equal to 8 bytes on 64 bits
> computers.
Not on "LLP64" platforms... there's a useful taxonomy of 64-bit data models on Wikipedia.
|
Fri 15 Feb 2013 10:02:54 PM UTC, SVN revision 22342:
Avoid problems with printf format for size_t value by hardcoding
the value. Assert that value is correct.
See gna bug #20513
(Browse SVN revision 22342) |
Fri 15 Feb 2013 10:00:39 PM UTC, comment #10:
I made a version that moves the asserts before this, and turns them to FC_STATIC_ASSERT.
I'm going to commit soon.
(file #17207)
|
Fri 15 Feb 2013 06:25:24 PM UTC, comment #9:
New patch attached which doesn't use the c-format (hard-coded strings).
(file #17206)
|
Fri 15 Feb 2013 03:36:47 PM UTC, comment #8:
> It can hold uint32_t, but not pointer or size_t on win64.
I am sorry for the noise I caused... But I thought that sizeof(long) were equal to 8 bytes on 64 bits computers.
|
Fri 15 Feb 2013 03:27:06 PM UTC, comment #7:
> The cast to (unsigned long) is used a bit everywhere in the
> code..
It can hold uint32_t, but not pointer or size_t on win64.
|
Fri 15 Feb 2013 03:03:34 PM UTC, comment #6:
The cast to (unsigned long) is used a bit everywhere in the code...
> We can/should move the fc_assert(sizeof(x) == 4) earlier in the
> function, before one tries to read 4 bytes to sizeof(x) block.
Yes. And it could also be replaced by FC_STATIC_ASSERT() here I guess.
|
Fri 15 Feb 2013 02:59:07 PM UTC, comment #5:
This is proving harder than I expected
- My MinGW compiler does not support "%zd" (C99 feature)
- We cannot rely on inttypes.h to exist, nor has it format identifier that is guaranteed to match site_t on all platforms
- Casting size_t to unsigned long wouldn't work on win64 (we recently got that otherwise supported) as there size_t is bigger than long
But myabe we are trying to fix wrong error here. Why those messages even are like that? Look for dio_get_uint32(): It tries to read 4 bytes, and when it fails, it tries to figure out number of bytes it tried to read with sizeof(). The same value should be used for both reading and to be in log message. Either we get it to variable and use that variable, or we use same hardcoded value for both. Given the problem in this ticket, we should go by hardcoding. We can/should move the fc_assert(sizeof(x) == 4) earlier in the function, before one tries to read 4 bytes to sizeof(x) block.
|
Fri 15 Feb 2013 02:11:52 PM UTC, comment #4:
Casts are no good! It just prevents the warning, but not the bug of using another size variable than what there is memory for.
Proper fix will take me a couple of moments...
|
Fri 15 Feb 2013 02:10:44 PM UTC, comment #3:
This one works for me.
(file #17204)
|
Fri 15 Feb 2013 02:08:29 PM UTC, comment #2:
It doesn't for me. I will add casts...
dataio.c: In function 'dio_get_uint8':
dataio.c:501:5: error: format '%ld' expects argument of type 'long int', but argument 7 has type 'unsigned int' [-Werror=format]
dataio.c: In function 'dio_get_uint16':
dataio.c:521:5: error: format '%ld' expects argument of type 'long int', but argument 7 has type 'unsigned int' [-Werror=format]
dataio.c: In function 'dio_get_uint32':
dataio.c:541:5: error: format '%ld' expects argument of type 'long int', but argument 7 has type 'unsigned int' [-Werror=format]
|
Fri 15 Feb 2013 02:06:13 PM UTC, comment #1:
This fixes it for me.
(file #17202)
|
Fri 15 Feb 2013 01:59:12 PM UTC, original submission:
As of r22341 --enable-debug (-Werror) build fails:
common/dataio.c: In function 'dio_get_uint8':
common/dataio.c:501:5: error: format '%d' expects argument of type 'int', but argument 7 has type 'long unsigned int' [-Werror=format]
common/dataio.c: In function 'dio_get_uint16':
common/dataio.c:520:5: error: format '%d' expects argument of type 'int', but argument 7 has type 'long unsigned int' [-Werror=format]
common/dataio.c: In function 'dio_get_uint32':
common/dataio.c:539:5: error: format '%d' expects argument of type 'int', but argument 7 has type 'long unsigned int' [-Werror=format]
|