[Ns-bugs] [Bug 137] New: Make Ipv4Address (uint32_t) constructor explicit
bugzilla-daemon@nsnam-www.ece.gatech.edu
bugzilla-daemon at nsnam-www.ece.gatech.edu
Tue Feb 12 07:07:24 PST 2008
http://www.nsnam.org/bugzilla/show_bug.cgi?id=137
Summary: Make Ipv4Address (uint32_t) constructor explicit
Product: ns-3
Version: pre-release
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P3
Component: node module
AssignedTo: ns-bugs at isi.edu
ReportedBy: gjcarneiro at gmail.com
I just lost a ton of time because of an accidental implicit conversion:
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (Ipv4Address address, Ipv4Address localInterface)
{
[...]
}
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (uint16_t port)
{
return Allocate (Ipv4Address::GetAny (), port);
}
In this case, Allocate (Ipv4Address::GetAny (), port) ends up calling
Ipv4EndPointDemux::Allocate (Ipv4Address address, Ipv4Address localInterface),
because the 'uint16_t port' parameter was being implicitly converted to
Ipv4Address (!). The solution is to add an 'explicit' keyword to the
constructor. It doesn't even break any existing NS-3 code.
diff -r 084b07dceafb src/node/ipv4-address.h
--- a/src/node/ipv4-address.h Mon Feb 11 14:46:44 2008 +0000
+++ b/src/node/ipv4-address.h Tue Feb 12 15:06:34 2008 +0000
@@ -40,7 +40,7 @@ public:
* input address is in host order.
* \param address The host order 32-bit address
*/
- Ipv4Address (uint32_t address);
+ explicit Ipv4Address (uint32_t address);
/**
* \brief Constructs an Ipv4Address by parsing a the input C-string
*
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Ns-bugs
mailing list