Bug 2042

Summary: src/lte/model/a3-rsrp-handover-algorithm.cc:137:79: error: overflow in implicit constant conversion [-Werror=overflow] uint8_t bestNeighbourRsrp = -std::numeric_limits<double>::infinity ();
Product: ns-3 Reporter: Manuel Rüger <mrueg>
Component: lteAssignee: Budiarto Herman <buherman>
Status: RESOLVED FIXED    
Severity: normal CC: nicola, ns-bugs, tomh
Priority: P3    
Version: pre-release   
Hardware: PC   
OS: Linux   
Attachments: Fixes build with gcc-4.9

Description Manuel Rüger 2015-01-21 12:54:27 UTC
With gcc-4.9:

../src/lte/model/a3-rsrp-handover-algorithm.cc: In member function ‘virtual void ns3::A3RsrpHandoverAlgorithm::DoReportUeMeas(uint16_t, ns3::LteRrcSap::MeasResults)’:
../src/lte/model/a3-rsrp-handover-algorithm.cc:137:79: error: overflow in implicit constant conversion [-Werror=overflow]
           uint8_t bestNeighbourRsrp = -std::numeric_limits<double>::infinity ();
                                                                               ^
cc1plus: all warnings being treated as errors
Waf: Leaving directory `/home/mrueg/Masterarbeit/tor-ns3/build'
Build failed
 -> task in 'ns3-lte' failed (exit status 1): 
        {task 140428977594512: cxx a3-rsrp-handover-algorithm.cc -> a3-rsrp-handover-algorithm.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..', '-I/usr/include/libxml2', '-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_SQLITE3=1', '-DHAVE_IF_TUN_H=1', '-DHAVE_GSL=1', '../src/lte/model/a3-rsrp-handover-algorithm.cc', '-c', '-o', 'src/lte/model/a3-rsrp-handover-algorithm.cc.1.o']
Comment 1 Manuel Rüger 2015-01-22 09:47:39 UTC
Created attachment 1948 [details]
Fixes build with gcc-4.9

This merely fixes build with gcc-4.9, not sure if it is correct as I don't use the LTE model.
Comment 2 Tom Henderson 2015-01-27 01:15:59 UTC
I'm curious, which compiler version exhibits this?  We have a gcc-4.9.2 buildslave (Fedora 21) that is not producing this error.
Comment 3 Manuel Rüger 2015-01-27 07:17:38 UTC
gcc --version
gcc (Gentoo 4.9.2 p1.0, pie-0.6.2) 4.9.2

I guess this might be caused by using -std=c++11?
Comment 4 Tom Henderson 2015-01-28 18:39:03 UTC
(In reply to Manuel Rüger from comment #3)
> gcc --version
> gcc (Gentoo 4.9.2 p1.0, pie-0.6.2) 4.9.2
> 
> I guess this might be caused by using -std=c++11?

I was able to reproduce by configuring in this way:

 CPPFLAGS="-O0 -g3 -Wall -Werror -std=c++11" ./waf configure --enable-examples --enable-tests --disable-gtk -d optimized


I will assign to Budi to either accept the proposed fix or propose something else.
Comment 5 Nicola Baldo 2015-01-29 05:41:02 UTC
This should fix it in a correct way. Feel free to reopen the bug if you think the resolution is incorrect.

changeset:   11177:8ff9047464ea
tag:         tip
user:        Nicola Baldo <nbaldo@cttc.es>
date:        Thu Jan 29 11:36:56 2015 +0100
summary:     fixed Bug 2042 - src/lte/model/a3-rsrp-handover-algorithm.cc:137:79: error: overflow in implicit constant conversion
Comment 6 Budiarto Herman 2015-01-29 09:54:00 UTC
I agree with Nicola's fix (set the variable to zero).