#121 Warnings building 64-bit libpng with Visual Studio

open-accepted
5
2008-01-11
2008-01-10
Arvan
No

I'm trying to build libpng 1.2.24 with Visual Studio 2005 and get a number of warnings for the x64 platform when size_t variables are assigned to int or png_uint_32 variables or passed to functions taking these as arguments.

The warnings are:

Warning 1 warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data d:\svn\trunk\Software\libpng\pngwutil.c 177
Warning 2 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwutil.c 1349
Warning 3 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwutil.c 1567
Warning 4 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwio.c 53
Warning 5 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngset.c 398
Warning 6 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngset.c 414
Warning 7 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngset.c 436
Warning 8 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngset.c 690
Warning 9 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngset.c 980
Warning 10 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngset.c 1025
Warning 11 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngset.c 1048
Warning 12 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 218
Warning 13 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 242
Warning 14 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 308
Warning 15 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 1067
Warning 16 warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 1160
Warning 17 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 3018
Warning 18 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 527
Warning 19 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 543
Warning 20 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 708
Warning 21 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 731
Warning 22 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 1280

Some of these are fixable by making local changes, and I have attached proposed edits that remove 4 warnings.

Others require more extensive edits, for example many would be fixed if the signatures of png_malloc and png_malloc_warn were changed to use png_size_t rather than png_uint_32, but I can't follow the ramifications of that for other platforms.

Discussion

  • Arvan
    Arvan
    2008-01-10

    proposed edits to remove some of the warnings

     
    Attachments
  • Logged In: YES
    user_id=7859
    Originator: NO

    Have you tried libpng-1.4.0beta19? It's out of date, but there was some work done on problems with size_t, and it would be good to know if that helps.

     
    • assigned_to: nobody --> glennrp
    • status: open --> open-accepted
     
  • Logged In: YES
    user_id=7859
    Originator: NO

    We don't want to change signatures until the next binary-incompatible release (1.4.0).

     
  • Arvan
    Arvan
    2008-01-15

    Logged In: YES
    user_id=1869599
    Originator: YES

    I have tried 1.4.0beta19 and it gives 21 warnings, rather more are fixable by changing the types of local variables, but I think the signature of png_write_chunk_start() and definition of png_structp may still need to change in order to silence them all.

    Here are the warnings:

    Warning 1 warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data d:\svn\trunk\Software\libpng\pngwutil.c 209
    Warning 2 warning C4267: 'function' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwutil.c 1377
    Warning 3 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwutil.c 1596
    Warning 4 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwutil.c 2127
    Warning 5 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwtran.c 257
    Warning 6 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngwio.c 48
    Warning 7 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngtrans.c 188
    Warning 8 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngtrans.c 201
    Warning 9 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngtrans.c 214
    Warning 10 warning C4267: '=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 1071
    Warning 11 warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 1164
    Warning 12 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 2711
    Warning 13 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 2726
    Warning 14 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 2744
    Warning 15 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrutil.c 2769
    Warning 16 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrtran.c 1579
    Warning 17 warning C4267: 'initializing' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngrtran.c 1592
    Warning 18 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 527
    Warning 19 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 543
    Warning 20 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 707
    Warning 21 warning C4267: '-=' : conversion from 'size_t' to 'png_uint_32', possible loss of data d:\svn\trunk\Software\libpng\pngpread.c 730

     
  • Arvan
    Arvan
    2008-01-15

    Local changes to silence 14 of the lpng1.4.0beta19 warnings

     
    Attachments
  • Arvan
    Arvan
    2008-01-15

    Logged In: YES
    user_id=1869599
    Originator: YES

    File Added: x64changes.zip