lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Warnings with gcc-8.2


From: Greg Chicares
Subject: [lmi] Warnings with gcc-8.2
Date: Tue, 19 Mar 2019 19:41:37 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

Debian "buster" now has MinGW-w64 gcc-8.2, so I tried using it to
build lmi and all the libraries we build from source. I haven't
tested the binaries yet, but I did get everything to build after
I suppressed three warning options thus for lmi binaries:
    -Wno-cast-function-type
    -Wno-noexcept
    -Wno-useless-cast
The warnings quoted below are so long that I'll separate sections
with nine consecutive hyphens.

---------

wxWidgets rebuilt with no warnings at all except this:

i686-w64-mingw32-gcc -c -o wxtiff_tif_predict.o -DNDEBUG 
-I/cache_for_lmi/vcs/wxWidgets/src/zlib -I/cache_for_lmi/vcs/wxWidgets/src/jpeg 
-I/opt/lmi/wx-scratch/lmi-gcc-8.2-win32/src/tiff/libtiff 
-I/cache_for_lmi/vcs/wxWidgets/src/tiff/libtiff  -D_FILE_OFFSET_BITS=64 
-I/opt/lmi/wx-scratch/lmi-gcc-8.2-win32/lib/wx/include/i686-w64-mingw32-msw-unicode-3.1
 -I/cache_for_lmi/vcs/wxWidgets/include -I/opt/lmi/local/include -mthreads 
-Wall -Wundef -O2 -mthreads -fno-omit-frame-pointer  
/cache_for_lmi/vcs/wxWidgets/src/tiff/libtiff/tif_predict.c

/cache_for_lmi/vcs/wxWidgets/src/tiff/libtiff/tif_predict.c:281:1: warning: 
'unsigned-integer-overflow' attribute directive ignored [-Wattributes]
 {
 ^

Presumably that's harmless, especially because AFAIK we don't actually use TIFF.
The relevant part of the source file is:

    272 /* Remarks related to C standard compliance in all below functions : */
    273 /* - to avoid any undefined behaviour, we only operate on unsigned 
types */
    274 /*   since the behaviour of "overflows" is defined (wrap over) */
    275 /* - when storing into the byte stream, we explicitly mask with 0xff so 
*/
    276 /*   as to make icc -check=conversions happy (not necessary by the 
standard) */
    277 
    278 TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
    279 static int
    280 horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)
    281 {

so I guess that macro TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW introduces some
attribute that gcc-8.2 ignores.

---------

Turning to lmi itself, '-Wno-useless-cast' suppresses diagnostics like this:

In file included from /opt/lmi/third_party/include/boost/mpl/int.hpp:20,
                 from /opt/lmi/third_party/include/boost/mpl/lambda_fwd.hpp:23,
                 from 
/opt/lmi/third_party/include/boost/mpl/aux_/na_spec.hpp:18,
                 from /opt/lmi/third_party/include/boost/mpl/or.hpp:24,
                 from 
/opt/lmi/third_party/include/boost/iterator/interoperable.hpp:11,
                 from 
/opt/lmi/third_party/include/boost/iterator/iterator_facade.hpp:11,
                 from /opt/lmi/third_party/include/boost/filesystem/path.hpp:16,
                 from 
/opt/lmi/third_party/include/boost/filesystem/operations.hpp:18,
                 from /opt/lmi/src/lmi/global_settings.hpp:30,
                 from /opt/lmi/src/lmi/data_directory.cpp:27:
/opt/lmi/third_party/include/boost/mpl/aux_/static_cast.hpp:24:66: error: 
useless cast to type 'int' [-Werror=useless-cast]
 #   define BOOST_MPL_AUX_STATIC_CAST(T, expr) static_cast<T>(expr)
                                                                  ^
/opt/lmi/third_party/include/boost/mpl/aux_/integral_wrapper.hpp:36:95: note: 
in definition of macro 'AUX_WRAPPER_INST'
 #       define AUX_WRAPPER_INST(value) 
BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::AUX_WRAPPER_NAME< value >
                                                                                
               ^~~~~
/opt/lmi/third_party/include/boost/mpl/aux_/integral_wrapper.hpp:72:31: note: 
in expansion of macro 'BOOST_MPL_AUX_STATIC_CAST'
     typedef AUX_WRAPPER_INST( 
BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value + 1)) ) next;
                               ^~~~~~~~~~~~~~~~~~~~~~~~~

Years ago, I might have patched 'boost/mpl/aux_/static_cast.hpp' to avoid that,
but I'm hoping that, with gcc-8.2, we'll be able to remove every dependency on
the boost filesystem library, so that this old legacy code will no longer be
used at all. In the meantime, it's okay to suppress the useless-cast warning.

---------

'-Wno-cast-function-type' suppresses diagnostics like this:

/opt/lmi/src/lmi/wx_utility.hpp: In instantiation of 'To c_cast(From) [with To 
= void (wxEvtHandler::*)(wxEvent&); From = void 
(wxEvtHandler::*)(wxKeyEvent&)]':
/opt/lmi/src/lmi/wx_utility.hpp:97:20:   required from 'void 
Connect(wxEvtHandler*, wxEventType, Return (Class::*)(Argument), int, 
wxEvtHandler*) [with Return = void; Class = {anonymous}::InputSequenceTextCtrl; 
Argument = wxKeyEvent&; wxEventType = int]'
/opt/lmi/src/lmi/input_sequence_entry.cpp:1359:13:   required from here
/opt/lmi/src/lmi/wx_utility.hpp:52:12: error: cast between incompatible pointer 
to member types from 'void (wxEvtHandler::*)(wxKeyEvent&)' to 'void 
(wxEvtHandler::*)(wxEvent&)' [-Werror=cast-function-type]

IIRC, I added 'c_cast' to encapsulate usage of C-style casts in code that
used wx facilities in what was an idiomatic way, at least at the time. It
would seem that C-style casts used to work with pointers-to-member, but no
longer do. Vadim, do you see an easy way to rewrite lmi's function template:

  /// Function template c_cast() performs an explicit type conversion
  /// (C++98 5.4), which is inherently unsafe. Its sole virtue is that
  /// it is easily searched for.

  template<typename To, typename From>
  To c_cast(From z)
  {
      return (To)(z);
  }

...so that this sort of cast compiles cleanly with this warning enabled?

In case it helps, this 'lmi/wx_utility.hpp' diagnostic occurs in exactly
the following contexts:

from 'void (wxEvtHandler::*)(wxBookCtrlEvent&)' to 'void 
(wxEvtHandler::*)(wxEvent&)' [-Werror=cast-function-type]
from 'void (wxEvtHandler::*)(wxChildFocusEvent&)' to 'void 
(wxEvtHandler::*)(wxEvent&)' [-Werror=cast-function-type]
from 'void (wxEvtHandler::*)(wxCommandEvent&)' to 'void 
(wxEvtHandler::*)(wxEvent&)' [-Werror=cast-function-type]
from 'void (wxEvtHandler::*)(wxInitDialogEvent&)' to 'void 
(wxEvtHandler::*)(wxEvent&)' [-Werror=cast-function-type]
from 'void (wxEvtHandler::*)(wxKeyEvent&)' to 'void 
(wxEvtHandler::*)(wxEvent&)' [-Werror=cast-function-type]
from 'void (wxEvtHandler::*)(wxUpdateUIEvent&)' to 'void 
(wxEvtHandler::*)(wxEvent&)' [-Werror=cast-function-type]

---------

'-Wno-noexcept' suppresses diagnostics like this:

/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/type_traits: In 
instantiation of 'constexpr bool std::__call_is_nt(std::__invoke_other) [with 
_Fn = const wxIntegerHash&; _Args = {const long int&}]':
/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/type_traits:2663:34:   
required by substitution of 'template<bool __v> using __bool_constant = 
std::integral_constant<bool, __v> [with bool __v = std::__call_is_nt<const 
wxIntegerHash&, const long int&>((std::__result_of_success<unsigned int, 
std::__invoke_other>::__invoke_type{}, std::__result_of_success<unsigned int, 
std::__invoke_other>::__invoke_type()))]'
/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/type_traits:2661:12:   
required from 'struct std::__call_is_nothrow<std::__invoke_result<const 
wxIntegerHash&, const long int&>, const wxIntegerHash&, const long int&>'
/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/type_traits:131:12:   
required from 'struct std::__and_<std::__is_invocable<const wxIntegerHash&, 
const long int&>, std::__call_is_nothrow<std::__invoke_result<const 
wxIntegerHash&, const long int&>, const wxIntegerHash&, const long int&> >'
/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/type_traits:2673:12:   
required from 'struct std::__is_nothrow_invocable<const wxIntegerHash&, const 
long int&>'
/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/type_traits:131:12:   
required from 'struct std::__and_<std::__is_fast_hash<wxIntegerHash>, 
std::__is_nothrow_invocable<const wxIntegerHash&, const long int&> >'
/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/type_traits:142:31:   
required from 'struct 
std::__not_<std::__and_<std::__is_fast_hash<wxIntegerHash>, 
std::__is_nothrow_invocable<const wxIntegerHash&, const long int&> > >'
/usr/lib/gcc/i686-w64-mingw32/8.2-win32/include/c++/bits/unordered_map.h:104:66:
   required from 'class std::unordered_map<long int, long int, wxIntegerHash, 
wxIntegerEqual>'
/opt/lmi/local/include/wx-3.1/wx/generic/grid.h:2007:25:   required from here
/opt/lmi/local/include/wx-3.1/wx/hashmap.h:509:12: error: but 'size_t 
wxIntegerHash::operator()(long int) const' does not throw; perhaps it should be 
declared 'noexcept' [-Werror=noexcept]

Usually I'd expect a gcc diagnostic like that to have a capitalized initial
fragment of a sentence some lines before "error: but [...] does not throw",
but I can't find the beginning of that sentence anywhere. Anyway, I guess
it's pretty clear what the compiler is saying; Vadim, is that something
that should (and readily can) be addressed in wx?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]