[Ns-bugs] [Bug 486] Patches for compilation with icc
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Wed Feb 4 12:32:02 PST 2009
http://www.nsnam.org/bugzilla/show_bug.cgi?id=486
--- Comment #3 from TimoB <timo.bingmann at student.kit.edu> 2009-02-04 15:32:02 EDT ---
Yes, sorry, some are warnings some are errors.
(In reply to comment #2)
> (From update of attachment 368 [details])
> Eh ? The following change can't possibly be right: what is the error message
> output by icc ?
This is about the default arguments, they should only be declared in the
function declaration.
../src/core/object.h(406): warning #845: specifying a default argument when
redeclaring an unreferenced function template is nonstandard
CreateObject (std::string n1 = "", const AttributeValue & v1 =
EmptyAttributeValue (),
^
../src/core/object.h(406): warning #350: redefinition of default argument
CreateObject (std::string n1 = "", const AttributeValue & v1 =
EmptyAttributeValue (),
^
> >diff -r 3e819441bc75 -r 0ad61c84f3c6 src/core/object.h
> >--- a/src/core/object.h Tue Feb 03 06:56:47 2009 -0800
> >+++ b/src/core/object.h Wed Feb 04 13:08:04 2009 +0100
> >@@ -403,15 +403,15 @@ Ptr<T> CreateObject (const AttributeList
> >
> > template <typename T>
> > Ptr<T>
> >-CreateObject (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (),
> >- std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (),
> >- std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (),
> >- std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (),
> >- std::string n5 = "", const AttributeValue & v5 = EmptyAttributeValue (),
> >- std::string n6 = "", const AttributeValue & v6 = EmptyAttributeValue (),
> >- std::string n7 = "", const AttributeValue & v7 = EmptyAttributeValue (),
> >- std::string n8 = "", const AttributeValue & v8 = EmptyAttributeValue (),
> >- std::string n9 = "", const AttributeValue & v9 = EmptyAttributeValue ())
> >+CreateObject (std::string n1 , const AttributeValue & v1,
> >+ std::string n2 , const AttributeValue & v2,
> >+ std::string n3 , const AttributeValue & v3,
> >+ std::string n4 , const AttributeValue & v4,
> >+ std::string n5 , const AttributeValue & v5,
> >+ std::string n6 , const AttributeValue & v6,
> >+ std::string n7 , const AttributeValue & v7,
> >+ std::string n8 , const AttributeValue & v8,
> >+ std::string n9 , const AttributeValue & v9)
> > {
> > AttributeList attributes;
> > if (n1 == "")
>
> What warning are you fixing below ?
It's an error, which I cannot tell you why it occurs:
../src/internet-stack/ipv4-l3-protocol.cc(1071): error: cast to type
"ns3::Ipv4Address ()" is not allowed
if ((interface->GetAddress ()) != (Ipv4Address ())
^
../src/internet-stack/ipv4-l3-protocol.cc(1072): error: expected an expression
&& (interface->GetNetworkMask ()) != (Ipv4Mask ()))
^
> >diff -r 3e819441bc75 -r 0ad61c84f3c6 src/internet-stack/ipv4-l3-protocol.cc
> >--- a/src/internet-stack/ipv4-l3-protocol.cc Tue Feb 03 06:56:47 2009 -0800
> >+++ b/src/internet-stack/ipv4-l3-protocol.cc Wed Feb 04 13:08:04 2009 +0100
> >@@ -1068,8 +1068,8 @@ Ipv4L3Protocol::SetUp (uint32_t i)
> > // If interface address and network mask have been set, add a route
> > // to the network of the interface (like e.g. ifconfig does on a
> > // Linux box)
> >- if ((interface->GetAddress ()) != (Ipv4Address ())
> >- && (interface->GetNetworkMask ()) != (Ipv4Mask ()))
> >+ if ( ! interface->GetAddress ().IsEqual (Ipv4Address ())
> >+ && (interface->GetNetworkMask ()) != (Ipv4Mask ()))
> > {
> > AddNetworkRouteTo (interface->GetAddress ().CombineMask (interface->GetNetworkMask ()),
> > interface->GetNetworkMask (), i);
>
> This is not really a warning fix, right ?
Warning about comparision of unsigned int >= 0. I changed the code to actually
compare something.
> >diff -r 3e819441bc75 -r 0ad61c84f3c6 src/node/queue.cc
> >--- a/src/node/queue.cc Tue Feb 03 06:56:47 2009 -0800
> >+++ b/src/node/queue.cc Wed Feb 04 13:08:04 2009 +0100
> >@@ -84,12 +84,12 @@ Queue::Dequeue (void)
> >
> > if (packet != 0)
> > {
> >+ NS_ASSERT (m_nBytes >= packet->GetSize ());
> >+ NS_ASSERT (m_nPackets > 0);
> >+
> > m_nBytes -= packet->GetSize ();
> > m_nPackets--;
> >
> >- NS_ASSERT (m_nBytes >= 0);
> >- NS_ASSERT (m_nPackets >= 0);
> >-
> > NS_LOG_LOGIC("m_traceDequeue (packet)");
> >
> > m_traceDequeue (packet);
>
> What warning are you fixing below ? LLU is not very portable so, adding:
> uint64_t pow10 (uint8_t n)
> {
> NS_ASSERT (n > 0);
> uint64_t result = 1;
> for (uint8_t i = 0; i < n; i++)
> {
> result *= 10;
> }
> return result;
> }
> would be probably more portable.
Interesting to talk about portability between compilers here ;).
This is actually a runtime error. Any example program will segfault, because
these static consts are incorrectly initialized, gdb says they are 0 at
segfault time.
Your idea with pow10 did not work.
The issue is about initialization order: in my dump WifiMac::GetDefaultSifs()
is called during initialization _before_ the pow10() is calculated. SIFS is
returned with MicroSeconds(), which uses one of the factors.
static const uint64_t MS_FACTOR = (uint64_t)1000;
static const uint64_t US_FACTOR = (uint64_t)1000000;
static const uint64_t NS_FACTOR = (uint64_t)1000000 * (uint64_t)1000;
static const uint64_t PS_FACTOR = (uint64_t)1000000 * (uint64_t)1000000;
static const uint64_t FS_FACTOR = (uint64_t)1000000 * (uint64_t)1000000 *
(uint64_t)1000;
The above works. The compilers (gcc/icc) seem to be able to fold the
expression.
> >diff -r 3e819441bc75 -r 0ad61c84f3c6 src/simulator/time.cc
> >--- a/src/simulator/time.cc Tue Feb 03 06:56:47 2009 -0800
> >+++ b/src/simulator/time.cc Wed Feb 04 13:08:04 2009 +0100
> >@@ -32,11 +32,11 @@ namespace ns3 {
> >
> > namespace TimeStepPrecision {
> >
> >-static const uint64_t MS_FACTOR = (uint64_t)pow(10,3);
> >-static const uint64_t US_FACTOR = (uint64_t)pow(10,6);
> >-static const uint64_t NS_FACTOR = (uint64_t)pow(10,9);
> >-static const uint64_t PS_FACTOR = (uint64_t)pow(10,12);
> >-static const uint64_t FS_FACTOR = (uint64_t)pow(10,15);
> >+static const uint64_t MS_FACTOR = 1000LLU;
> >+static const uint64_t US_FACTOR = 1000000LLU;
> >+static const uint64_t NS_FACTOR = 1000000000LLU;
> >+static const uint64_t PS_FACTOR = 1000000000000LLU;
> >+static const uint64_t FS_FACTOR = 1000000000000000LLU;
> > static uint64_t g_tsPrecFactor = NS_FACTOR;
> >
> > static GlobalValue g_precisionDefaultValue ("TimeStepPrecision",
>
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Ns-bugs
mailing list