Bug 2031 - callback.h:1249: warning: dereferencing type-punned pointer will break strict-aliasing rules with gcc 4.2.1 on freebsd 9.3
callback.h:1249: warning: dereferencing type-punned pointer will break strict...
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
pre-release
PC FreeBSD
: P5 normal
Assigned To: Mathieu Lacage
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-12-17 12:06 UTC by Vedran Miletić
Modified: 2014-12-18 12:46 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vedran Miletić 2014-12-17 12:06:35 UTC
On FreeBSD 9.3 with GCC 4.2.1:

$ uname -a
FreeBSD inf2-freebsd 9.3-RELEASE-p5 FreeBSD 9.3-RELEASE-p5 #0: Mon Nov  3 22:38:58 UTC 2014     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

$ gcc -v
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070831 patched [FreeBSD]

build fails with:

$ ./waf build
Waf: Entering directory `/usr/home/vedranm/workspace/ns-3-allinone/ns-3-dev/build-clang'
[ 812/2182] cxx: examples/stats/wifi-example-apps.cc -> build-clang/examples/stats/wifi-example-apps.cc.1.o
cc1plus: warnings being treated as errors
./ns3/callback.h: In member function 'void ns3::Callback<R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::DoAssign(ns3::Ptr<const ns3::CallbackImplBase>) [with R = void, T1 = ns3::Ptr<const ns3::Packet>, T2 = ns3::empty, T3 = ns3::empty, T4 = ns3::empty, T5 = ns3::empty, T6 = ns3::empty, T7 = ns3::empty, T8 = ns3::empty, T9 = ns3::empty]':
./ns3/callback.h:1214:   instantiated from 'void ns3::Callback<R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::Assign(const ns3::CallbackBase&) [with R = void, T1 = ns3::Ptr<const ns3::Packet>, T2 = ns3::empty, T3 = ns3::empty, T4 = ns3::empty, T5 = ns3::empty, T6 = ns3::empty, T7 = ns3::empty, T8 = ns3::empty, T9 = ns3::empty]'
./ns3/traced-callback.h:128:   instantiated from 'void ns3::TracedCallback<T1, T2, T3, T4, T5, T6, T7, T8>::ConnectWithoutContext(const ns3::CallbackBase&) [with T1 = ns3::Ptr<const ns3::Packet>, T2 = ns3::empty, T3 = ns3::empty, T4 = ns3::empty, T5 = ns3::empty, T6 = ns3::empty, T7 = ns3::empty, T8 = ns3::empty]'
./ns3/trace-source-accessor.h:99:   instantiated from 'bool ns3::DoMakeTraceSourceAccessor(SOURCE T::*)::Accessor::ConnectWithoutContext(ns3::ObjectBase*, const ns3::CallbackBase&) const [with T = Sender, SOURCE = ns3::TracedCallback<ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>]'
../examples/stats/wifi-example-apps.cc:331:   instantiated from here
./ns3/callback.h:1249: warning: dereferencing type-punned pointer will break strict-aliasing rules
./ns3/callback.h: In member function 'void ns3::Callback<R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::DoAssign(ns3::Ptr<const ns3::CallbackImplBase>) [with R = void, T1 = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, T2 = ns3::Ptr<const ns3::Packet>, T3 = ns3::empty, T4 = ns3::empty, T5 = ns3::empty, T6 = ns3::empty, T7 = ns3::empty, T8 = ns3::empty, T9 = ns3::empty]':
./ns3/callback.h:1214:   instantiated from 'void ns3::Callback<R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::Assign(const ns3::CallbackBase&) [with R = void, T1 = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, T2 = ns3::Ptr<const ns3::Packet>, T3 = ns3::empty, T4 = ns3::empty, T5 = ns3::empty, T6 = ns3::empty, T7 = ns3::empty, T8 = ns3::empty, T9 = ns3::empty]'
./ns3/traced-callback.h:139:   instantiated from 'void ns3::TracedCallback<T1, T2, T3, T4, T5, T6, T7, T8>::Connect(const ns3::CallbackBase&, std::string) [with T1 = ns3::Ptr<const ns3::Packet>, T2 = ns3::empty, T3 = ns3::empty, T4 = ns3::empty, T5 = ns3::empty, T6 = ns3::empty, T7 = ns3::empty, T8 = ns3::empty]'
./ns3/trace-source-accessor.h:108:   instantiated from 'bool ns3::DoMakeTraceSourceAccessor(SOURCE T::*)::Accessor::Connect(ns3::ObjectBase*, std::string, const ns3::CallbackBase&) const [with T = Sender, SOURCE = ns3::TracedCallback<ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>]'
../examples/stats/wifi-example-apps.cc:331:   instantiated from here
./ns3/callback.h:1249: warning: dereferencing type-punned pointer will break strict-aliasing rules
Waf: Leaving directory `/usr/home/vedranm/workspace/ns-3-allinone/ns-3-dev/build-clang'
Build failed
 -> task in 'wifi-example-sim' failed (exit status 1): 
        {task 34478518736: cxx wifi-example-apps.cc -> wifi-example-apps.cc.1.o}
['/usr/bin/g++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-pthread', '-I.', '-I..', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '../examples/stats/wifi-example-apps.cc', '-c', '-o', 'examples/stats/wifi-example-apps.cc.1.o']
Comment 1 Tom Henderson 2014-12-17 13:11:29 UTC
do we want to support gcc-4.2.1 anymore?
Comment 2 Vedran Miletić 2014-12-17 13:26:04 UTC
Yeah, that's a good question. I believe this is easy to fix, so it should not cause maintenance burden. I will take a look tomorrow or over the weekend.
Comment 3 Vedran Miletić 2014-12-18 12:46:38 UTC
changeset 11108	96c967086fdb
parent 11107 	647dbdb894d6
Fix compilation with GCC 4.2.1 on FreeBSD 9

Thanks to Domagoj Stolfa <shrinkd@gmail.com> for his aid in debugging this.