Bug 1678

Summary: C++11 compliance problem with std::pair
Product: ns-3 Reporter: Morten V. Pedersen <morten>
Component: internetAssignee: George Riley <riley>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, vedran
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: patch for the issue
Updated patch

Description Morten V. Pedersen 2013-05-09 04:55:54 UTC
Created attachment 1595 [details]
patch for the issue

What:
Improper use of std::make_pair. The problem is explained in this answer: http://stackoverflow.com/a/9642232
Fortunately this is very simple to fix (see patch).

Where:
ipv6-extension.cc line 350
ipv6-extension.cc line 614
ipv4-l3-protocol.cc line 1332

Reproduce: 
1. Clone the latest ns3-dev ("hg clone http://code.nsnam.org/ns-3-dev")
2. Open the ns3-dev/wscript in your favorite editor and add to the configure
   function env.append_value('CXXFLAGS', '--std=c++0x') to enable all the
   new c++11 sugar. 
3. Run "./waf configure"
4. Run "./waf build -v" and check that the files get compiled with the
   --std=c++0x option 

Fix:
See attached patch.
Comment 1 Vedran Miletić 2013-05-17 03:25:08 UTC
Hi Morten, you can also use

$ CXXFLAGS="--std=c++0x" ./waf configure
$ ./waf build

I will take a look at the patch.
Comment 2 Tommaso Pecorella 2013-05-17 07:54:28 UTC
+0.5.

There are some more occurrences where the make_pair isn't used correctly. Using grep I find:
src/internet/model/ipv4-l3-protocol.cc:  m_fragments.insert (it, std::make_pair<Ptr<Packet>, uint16_t> (fragment, fragmentOffset));
src/internet/model/ipv6-extension.cc:  std::pair<Ipv6Address, uint32_t> fragmentsId = std::make_pair<Ipv6Address, uint32_t> (src, identification);
src/internet/model/ipv6-extension.cc:          unfragmentablePart.push_back (std::make_pair<Ipv6ExtensionHeader *, uint8_t> (hopbyhopHeader, Ipv6Header::IPV6_EXT_HOP_BY_HOP));
src/internet/model/ipv6-extension.cc:          unfragmentablePart.push_back (std::make_pair<Ipv6ExtensionHeader *, uint8_t> (routingHeader, Ipv6Header::IPV6_EXT_ROUTING));
src/internet/model/ipv6-extension.cc:          unfragmentablePart.push_back (std::make_pair<Ipv6ExtensionHeader *, uint8_t> (destinationHeader, Ipv6Header::IPV6_EXT_DESTINATION));
src/internet/model/ipv6-extension.cc:  m_packetFragments.insert (it, std::make_pair<Ptr<Packet>, uint16_t> (fragment, fragmentOffset));

Update the patch to fix 'em all please, then feel free to push it.

T.
Comment 3 Morten V. Pedersen 2013-05-23 21:23:15 UTC
Created attachment 1602 [details]
Updated patch

Sorry for the delay, got busy with some other stuff. Anyway this patch should fix all uses of std::make_pair.
Comment 4 Tommaso Pecorella 2013-05-25 07:03:01 UTC
Pushed in changeset:   9813:16f65595bdf8