Bug 1474034

Summary: GCC 7 gives -Werror=maybe-uninitialized when compiling ns-3
Product: [Fedora] Fedora Reporter: Vedran Miletić <vedran>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: davejohansen, fweimer, jakub, jwakely, law, mpolacek
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-19 15:51:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vedran Miletić 2017-07-23 09:44:49 UTC
$ hg clone http://code.nsnam.org/ns-3-dev
$ cd ns-3-dev

Now, compiling in debug mode works fine:

$ ./waf configure
$ ./waf build

But compiling in optimized mode fails:

$ ./waf configure -d optimized
$ ./waf build
Waf: Entering directory `/home/vedranm/workspace/ns-3-allinone/ns-3-dev/build'
[1608/1955] Compiling src/lte/model/epc-mme.cc
In file included from ../src/lte/model/epc-mme.cc:25:0:
../src/lte/model/epc-s11-sap.h: In member function „void ns3::EpcMme::DoInitialUeMessage(uint64_t, uint16_t, uint64_t, uint16_t)”:
../src/lte/model/epc-s11-sap.h:183:10: greška: „msg.ns3::EpcS11SapSgw::CreateSessionRequestMessage::<anonymous>” may be used uninitialized in this function [-Werror=maybe-uninitialized]
   struct CreateSessionRequestMessage : public GtpcMessage
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

Waf: Leaving directory `/home/vedranm/workspace/ns-3-allinone/ns-3-dev/build'
Build failed
 -> task in 'ns3-lte' failed (exit status 1): 
	{task 139949836372048: cxx epc-mme.cc -> epc-mme.cc.1.o}
['/usr/lib64/ccache/g++', '-O3', '-g', '-Wall', '-Werror', '-march=native', '-fstrict-overflow', '-Wstrict-overflow=2', '-std=c++11', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-fPIC', '-pthread', '-I.', '-I..', '-I/usr/include/libxml2', '-DNS3_BUILD_PROFILE_OPTIMIZED', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '-DHAVE_NET_ETHERNET_H=1', '-DHAVE_PACKET_H=1', '-DHAVE_DL=1', '-DDL=1', '-DXML2=1', '-DHAVE_IF_TUN_H=1', '-DHAVE_GSL=1', '-DHAVE_SQLITE3=1', '-DHAVE_LIBXML2=1', '../src/lte/model/epc-mme.cc', '-c', '-o', '/home/vedranm/workspace/ns-3-allinone/ns-3-dev/build/src/lte/model/epc-mme.cc.1.o']

GCC 6 compiles both fine. Furthermore if in epc-mme.cc one replaces

EpcS11SapSgw::CreateSessionRequestMessage msg;

with

EpcS11SapSgw::CreateSessionRequestMessage msg {};

the code compiles fine. All my attempts at getting a minimal example that exhibits the same behaviour have unfortunately failed.

Should I provide the preprocessed source file?

Comment 1 Vedran Miletić 2017-09-19 15:51:01 UTC
Fixed in gcc-c++-7.2.1-2.fc26.x86_64.