Menu

#267 Build failure with GCC 6.1.1

None
closed
None
5
2018-07-31
2016-05-28
No

Freeimage fails to build with GCC 6.1.1.

Source/LibRawLite/./internal/dcraw_common.cpp: In member function void LibRaw::vng_interpolate():
Source/LibRawLite/./internal/dcraw_common.cpp:4545:3: error: narrowing conversion of 128 from int to signed char inside { } [-Wnarrowing]
}, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };
^
Source/LibRawLite/./internal/dcraw_common.cpp:4545:3: error: narrowing conversion of 136 from int to signed char inside { } [-Wnarrowing]
Makefile.gnu:64: recipe for target 'Source/LibRawLite/./internal/dcraw_common.o' failed
make[1]: *** [Source/LibRawLite/./internal/dcraw_common.o] Error 1

Explicit casts to signed char should be added in the array initialiser for values that fall outside of -128 -- 127 range to make GCC happy when compiling in C++14 mode (the default now in GCC 6.x).

Alternatively, compiling FreeImage in C++98 mode (-std=c++98) also fixes the issue.

Discussion

  • Fadi R

    Fadi R - 2017-02-24

    Hi, I'm pretty new new to programming and I'm not too clear on what needs to be done to fix the script:

    • I tried adding -std=c++98 to Makefile.mingw under CXXFLAGS ?= -O3 -fexceptions -std=c++98 (etc...) but that's not working.
    • I've researched what explict casting is but you said that it should be done if values fall outside of -128 to 127 which of none of the values in chood[] or terms[] do. Could you please elaborate on that? Thanks alot!
     
    • Davorin Učakar

      Davorin Učakar - 2017-02-24

      You have e.,g. 0x80 = 128 and 0x88 = 136 inside terms[].

      Here's my package (32-bit freeimage for 64-bit ArchLinux) that builds successfully (see PKGBUILD for build commands). Besides that bug there are also some string concatenating issues (see gcc5.patch).

       
  • Fadi R

    Fadi R - 2017-02-24

    High Davorin, thanks for getting back to me so quickly and for sharing your patch. I don't see any attachments or links though. If SourceForge's attachment system isn't working, could you email it to me? mo.mashi [at] gmail.com

     
  • Fadi R

    Fadi R - 2017-02-25

    Hey Davoring, as per your recommendation, I replaced:

    <freeimage3170.zip>/FreeImage/Source/LibRawLite/internal/dcraw_common.cpp (4523-4546)</freeimage3170.zip>

      static const signed char *cp, terms[] = {
        -2,-2,+0,-1,0,0x01, -2,-2,+0,+0,1,0x01, -2,-1,-1,+0,0,0x01,
        -2,-1,+0,-1,0,0x02, -2,-1,+0,+0,0,0x03, -2,-1,+0,+1,1,0x01,
        -2,+0,+0,-1,0,0x06, -2,+0,+0,+0,1,0x02, -2,+0,+0,+1,0,0x03,
        -2,+1,-1,+0,0,0x04, -2,+1,+0,-1,1,0x04, -2,+1,+0,+0,0,0x06,
        -2,+1,+0,+1,0,0x02, -2,+2,+0,+0,1,0x04, -2,+2,+0,+1,0,0x04,
        -1,-2,-1,+0,0,0x80, -1,-2,+0,-1,0,0x01, -1,-2,+1,-1,0,0x01,
        -1,-2,+1,+0,1,0x01, -1,-1,-1,+1,0,0x88, -1,-1,+1,-2,0,0x40,
        -1,-1,+1,-1,0,0x22, -1,-1,+1,+0,0,0x33, -1,-1,+1,+1,1,0x11,
        -1,+0,-1,+2,0,0x08, -1,+0,+0,-1,0,0x44, -1,+0,+0,+1,0,0x11,
        -1,+0,+1,-2,1,0x40, -1,+0,+1,-1,0,0x66, -1,+0,+1,+0,1,0x22,
        -1,+0,+1,+1,0,0x33, -1,+0,+1,+2,1,0x10, -1,+1,+1,-1,1,0x44,
        -1,+1,+1,+0,0,0x66, -1,+1,+1,+1,0,0x22, -1,+1,+1,+2,0,0x10,
        -1,+2,+0,+1,0,0x04, -1,+2,+1,+0,1,0x04, -1,+2,+1,+1,0,0x04,
        +0,-2,+0,+0,1,0x80, +0,-1,+0,+1,1,0x88, +0,-1,+1,-2,0,0x40,
        +0,-1,+1,+0,0,0x11, +0,-1,+2,-2,0,0x40, +0,-1,+2,-1,0,0x20,
        +0,-1,+2,+0,0,0x30, +0,-1,+2,+1,1,0x10, +0,+0,+0,+2,1,0x08,
        +0,+0,+2,-2,1,0x40, +0,+0,+2,-1,0,0x60, +0,+0,+2,+0,1,0x20,
        +0,+0,+2,+1,0,0x30, +0,+0,+2,+2,1,0x10, +0,+1,+1,+0,0,0x44,
        +0,+1,+1,+2,0,0x10, +0,+1,+2,-1,1,0x40, +0,+1,+2,+0,0,0x60,
        +0,+1,+2,+1,0,0x20, +0,+1,+2,+2,0,0x10, +1,-2,+1,+0,0,0x80,
        +1,-1,+1,+1,0,0x88, +1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40,
        +1,+0,+2,+1,0,0x10
      }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };
    

    with

      static const signed int termsint[] = {
        -2,-2,+0,-1,0,0x01, -2,-2,+0,+0,1,0x01, -2,-1,-1,+0,0,0x01,
        -2,-1,+0,-1,0,0x02, -2,-1,+0,+0,0,0x03, -2,-1,+0,+1,1,0x01,
        -2,+0,+0,-1,0,0x06, -2,+0,+0,+0,1,0x02, -2,+0,+0,+1,0,0x03,
        -2,+1,-1,+0,0,0x04, -2,+1,+0,-1,1,0x04, -2,+1,+0,+0,0,0x06,
        -2,+1,+0,+1,0,0x02, -2,+2,+0,+0,1,0x04, -2,+2,+0,+1,0,0x04,
        -1,-2,-1,+0,0,0x80, -1,-2,+0,-1,0,0x01, -1,-2,+1,-1,0,0x01,
        -1,-2,+1,+0,1,0x01, -1,-1,-1,+1,0,0x88, -1,-1,+1,-2,0,0x40,
        -1,-1,+1,-1,0,0x22, -1,-1,+1,+0,0,0x33, -1,-1,+1,+1,1,0x11,
        -1,+0,-1,+2,0,0x08, -1,+0,+0,-1,0,0x44, -1,+0,+0,+1,0,0x11,
        -1,+0,+1,-2,1,0x40, -1,+0,+1,-1,0,0x66, -1,+0,+1,+0,1,0x22,
        -1,+0,+1,+1,0,0x33, -1,+0,+1,+2,1,0x10, -1,+1,+1,-1,1,0x44,
        -1,+1,+1,+0,0,0x66, -1,+1,+1,+1,0,0x22, -1,+1,+1,+2,0,0x10,
        -1,+2,+0,+1,0,0x04, -1,+2,+1,+0,1,0x04, -1,+2,+1,+1,0,0x04,
        +0,-2,+0,+0,1,0x80, +0,-1,+0,+1,1,0x88, +0,-1,+1,-2,0,0x40,
        +0,-1,+1,+0,0,0x11, +0,-1,+2,-2,0,0x40, +0,-1,+2,-1,0,0x20,
        +0,-1,+2,+0,0,0x30, +0,-1,+2,+1,1,0x10, +0,+0,+0,+2,1,0x08,
        +0,+0,+2,-2,1,0x40, +0,+0,+2,-1,0,0x60, +0,+0,+2,+0,1,0x20,
        +0,+0,+2,+1,0,0x30, +0,+0,+2,+2,1,0x10, +0,+1,+1,+0,0,0x44,
        +0,+1,+1,+2,0,0x10, +0,+1,+2,-1,1,0x40, +0,+1,+2,+0,0,0x60,
        +0,+1,+2,+1,0,0x20, +0,+1,+2,+2,0,0x10, +1,-2,+1,+0,0,0x80,
        +1,-1,+1,+1,0,0x88, +1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40,
        +1,+0,+2,+1,0,0x10
      };
        signed char terms[384];
        for (int i = 0; i < 384; ++i){
      terms[i]= static_cast<signed char>(termsint[i]);
      }
      static const signed char *cp, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };
    

    It's compiling great now but I was just wondering if what I did was sound (with regards to setting the values of terms[] via static cast of an signed int). I also couldn't do the casting of terms[] if I declared it as a static constant signed char array. Should I try to convert it somehow to a constant array after the casting is done in order to avoid any run-time bugs. Would you know how I could do that?

     

    Last edit: Fadi R 2017-02-25
  • Hervé Drolon

    Hervé Drolon - 2018-07-31
    • status: open --> closed
    • assigned_to: Hervé Drolon
    • Group: -->
     
  • Hervé Drolon

    Hervé Drolon - 2018-07-31

    Closed in release 3.18.0 (new LibRaw library)
    Please open a new bug if your problem persist.

     

Log in to post a comment.