Menu

#61 GNU CC 4.8 compatibility: unused-local-typedefs

1.9
open
5
2017-03-31
2015-01-28
No

GCC 4.8 compatibility issue

../common_libs/thirdparty/stlsoft/include/stlsoft/stlsoft.h:1360:62: warning: typedef ‘ai’ locally defined but not used [-Wunused-local-typedefs]
# define STLSOFT_STATIC_ASSERT(expr) do { typedef int ai[(expr) ? 1 : -1]; } while(0)

Analysis:
GCC 4.8 has a new unused checking (or at least it is newly enabled by -Wall): unused-local-typedefs.

Our software is by default compiled with "-Wall", so we get a few dozen of these warnings merely by including stlsoft/stlsoft.h. Not to mention when compiling Pantheios.

How to modify STLSOFT_STATIC_ASSERT to prevent the warning?

Discussion

  • Ken

    Ken - 2015-04-09

    For a quick work-around, adding -Wno-unused-local-typedefs before -Wall in the makefile seems to result in a completed compile.

    (Obviously, a real fix would be better, but if you just need to get work done...)

     

    Last edit: Ken 2015-04-09
  • Mikko Koivunalho

    Hi, Ken,

    -Wno-unused-local-typedefs is what we have been using to quiet the warnings when building. A real fix is needed desperately, because 1) -Wno-unused-local-typedefs now prevents real warnings, aswell, and 2) using -Wno-unused-local-typedefs is ok with Pantheios part of the project, but forcing it on other parts prevents wider usage of STLSoft.

    Would be better to fix the STLSoft code, if it is at all possible. Or maybe quiet the warnings in some compiler specific ways, #define something perhaps?

     
  • Mikko Koivunalho

    I have created a pull request to fix this: https://github.com/synesissoftware/STLSoft-1.9/pull/2

    -# define STLSOFT_STATIC_ASSERT(expr) do { typedef int ai[(expr) ? 1 : -1]; } while(0)
    +# if defined(STLSOFT_COMPILER_IS_GCC) && GNUC >= 4 && GNUC_MINOR >= 8
    +# define STLSOFT_STATIC_ASSERT(expr) do { typedef int ai[(expr) ? 1 : -1] attribute((unused)); } while(0)
    +# else / Compiler is Gnu 4.8 or newer with -Wunused-local-typedefs included in -Wall. /
    +# define STLSOFT_STATIC_ASSERT(expr) do { typedef int ai[(expr) ? 1 : -1]; } while(0)
    +# endif / Compiler is Gnu 4.8 or newer with -Wunused-local-typedefs included in -Wall. /

     
  • Ludvik Jerabek

    Ludvik Jerabek - 2016-01-08

    Looks like this issue is related. I applied the patched version of slysoft.h however make throws the following error:

    Ensuring all STLSoft C source files are in UNIX format
    g++ -c -Wall -pedantic -Wno-long-long -Wno-unused-value -Wno-unused-function -Wno-array-bounds -Werror -D_REENTRANT -D_DEBUG -UNDEBUG -Dunix -DSHWILD_QUALITY_NO_USE_XCOVER -DPANTHEIOS_NO_AUTO_INIT -I../../include -I"/home/ludio/Desktop/stlsoft-1.9.124/include" -o util.be_parse.mt.debug.o ../../src/util/be.parse.cpp
    In file included from /home/ludio/Desktop/stlsoft-1.9.124/include/stlsoft/string/simple_string.hpp:106:0,
    from /home/ludio/Desktop/stlsoft-1.9.124/include/stlsoft/string/view_slice_functions.hpp:91,
    from ../../src/util/be.parse.cpp:51:
    /home/ludio/Desktop/stlsoft-1.9.124/include/stlsoft/conversion/sap_cast.hpp: In function ‘TO stlsoft::sap_cast(FROM)’:
    /home/ludio/Desktop/stlsoft-1.9.124/include/stlsoft/conversion/sap_cast.hpp:145:69: error: typedef ‘from_base_type’ locally defined but not used [-Werror=unused-local-typedefs]
    typedef ss_typename_type_k base_type_traits<from>::base_type from_base_type;
    ^
    /home/ludio/Desktop/stlsoft-1.9.124/include/stlsoft/conversion/sap_cast.hpp:146:69: error: typedef ‘to_base_type’ locally defined but not used [-Werror=unused-local-typedefs]
    typedef ss_typename_type_k base_type_traits<to>::base_type to_base_type;
    ^
    cc1plus: all warnings being treated as errors
    make: *** [util.be_parse.mt.debug.o] Error 1</to></from>

     
    • Mikko Koivunalho

      Hi, Ludvik.

      Can you send me the file be.parse.cpp (or a stripped down version of it)? I want to try to reproduce the error.

      which compiler version you are using?

       
  • Mikko Koivunalho

    Hi, Ludvik.

    Can you send me the file be.parse.cpp (or a stripped down version of it)? I want to try to reproduce the error.

    which compiler version you are using?

     
  • Mikko Koivunalho

    This is fixed in the version 1.9.125.

     
  • Ike To

    Ike To - 2017-03-31

    I think this is not completely resolved. When compiling Pantheios with GCC 4.8 I now have a lot fewer warnings, but still some are there, like this:

    In file included from /home/builder/include/stlsoft/string/simple_string.hpp:106:0,
                     from /home/builder/include/stlsoft/string/view_slice_functions.hpp:91,
                     from ../../src/util/be.parse.cpp:51:
    /home/builder/include/stlsoft/conversion/sap_cast.hpp: In function 'TO stlsoft::sap_cast(FROM)':
    /home/builder/include/stlsoft/conversion/sap_cast.hpp:145:69: warning: typedef 'from_base_type' locally defined but not used [-Wunused-local-typedefs]
         typedef ss_typename_type_k base_type_traits<FROM>::base_type    from_base_type;
                                                                         ^
    /home/builder/include/stlsoft/conversion/sap_cast.hpp:146:69: warning: typedef 'to_base_type' locally defined but not used [-Wunused-local-typedefs]
         typedef ss_typename_type_k base_type_traits<TO>::base_type      to_base_type;
    
     

Log in to post a comment.

Auth0 Logo