Bug 1367

Summary: [LLVM] error: using the result of an assignment as a condition without parentheses
Product: ns-3 Reporter: Gustavo J. A. M. Carneiro <gjcarneiro>
Component: ipv6Assignee: Tommaso Pecorella <tommaso.pecorella>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   

Description Gustavo J. A. M. Carneiro 2012-02-22 06:17:04 UTC
With clang++ (LLVM):

[ 838/1334] cxx: src/internet/model/ipv6-interface.cc -> build/src/internet/model/ipv6-interface.cc.1.o
11:15:47 runner ['/usr/bin/clang++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-Wno-array-bounds', '-fPIC', '-pthread', '-Ibuild', '-I.', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DSQLITE3=1', '-DHAVE_IF_TUN_H=1', '-DENABLE_GSL', '../src/internet/model/ipv6-interface.cc', '-c', '-o', 'src/internet/model/ipv6-interface.cc.1.o']
../src/internet/model/ipv6-l3-protocol.cc:436:18: error: using the result of an assignment as a condition without parentheses
      [-Werror,-Wparentheses]
      if (device = DynamicCast<LoopbackNetDevice> (m_node->GetDevice (i)))
          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/internet/model/ipv6-l3-protocol.cc:436:18: note: use '==' to turn this assignment into an equality comparison
      if (device = DynamicCast<LoopbackNetDevice> (m_node->GetDevice (i)))
                 ^
                 ==
../src/internet/model/ipv6-l3-protocol.cc:436:18: note: place parentheses around the assignment to silence this warning
      if (device = DynamicCast<LoopbackNetDevice> (m_node->GetDevice (i)))
                 ^
          (                                                              )
1 error generated.

It just needs extra parenthesis around the assignment.
Comment 1 Tommaso Pecorella 2012-02-23 18:26:22 UTC
Fixed, changeset 7739 - b521459d9d27