Bugzilla – Bug 2917
G++ doesn't like catching polymorphic exceptions by value
Last modified: 2018-05-19 22:58:56 EDT
Using the following version of g++ $ g++ --version g++ (GCC) 8.1.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. I get the following error when building NS3 ../src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc: In member function ‘virtual bool ns3::dot11s::IeBeaconTiming::operator==(const ns3::WifiInformationElement&) const’: ../src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc:209:15: error: catching polymorphic type ‘class std::bad_cast’ by value [-Werror=catch-value=] catch (std::bad_cast) ^~~~~~~~ cc1plus: all warnings being treated as errors Waf: Leaving directory `/home/mettinger/SNS3/ns-3-debug/build' Build failed -> task in 'ns3-mesh' failed (exit status 1): {task 139826318416080: cxx ie-dot11s-beacon-timing.cc -> ie-dot11s-beacon-timing.cc.1.o} ['/usr/bin/g++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-std=c++11', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-fPIC', '-pthread', '-I.', '-I..', '-DNS3_BUILD_PROFILE_DEBUG', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '-DHAVE_NET_ETHERNET_H=1', '-DHAVE_PACKET_H=1', '-DHAVE_IF_TUN_H=1', '-DHAVE_=1', '-DHAVE_GSL=1', '-DHAVE_SQLITE3=1', '../src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc', '-c', '-o', '/home/mettinger/SNS3/ns-3-debug/build/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc.1.o'] A simple fix is to catch (std::bad_cast&) instead.
was fixed a day earlier in changeset 13550:b9bd326fba19