Bug 1369 - [LLVM] error: comparison of unsigned expression < 0 is always false
[LLVM] error: comparison of unsigned expression < 0 is always false
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: dsdv
ns-3-dev
All All
: P5 normal
Assigned To: Hemanth Narra
:
Depends on:
Blocks: 1345
  Show dependency treegraph
 
Reported: 2012-02-22 06:24 UTC by Gustavo J. A. M. Carneiro
Modified: 2012-03-18 07:11 UTC (History)
2 users (show)

See Also:


Attachments
Removes the if that is never executed (645 bytes, patch)
2012-03-12 08:20 UTC, Daniel Camara
Details | Diff
patch to fix bug 1369 in dsdv-routing-protocol.cc (462 bytes, patch)
2012-03-17 21:00 UTC, Hemanth Narra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gustavo J. A. M. Carneiro 2012-02-22 06:24:01 UTC
With clang++ 2.9:

[ 856/1334] cxx: src/dsdv/model/dsdv-routing-protocol.cc -> build/src/dsdv/model/dsdv-routing-protocol.cc.1.o
../src/dsdv/model/dsdv-routing-protocol.cc:843:25: error: comparison of unsigned expression < 0 is always false
      [-Werror,-Wtautological-compare]
  if (allRoutes.size () < 0)
      ~~~~~~~~~~~~~~~~~ ^ ~
1 error generated.
Comment 1 Daniel Camara 2012-03-12 08:20:57 UTC
Created attachment 1355 [details]
Removes the if that is never executed

Patch to solve the "comparison of unsigned expression < 0 is always false"  error message of clang. The path removes the if, this solution should be evaluate by the maintainer of the module to be sure it is correct.
Comment 2 Tommaso Pecorella 2012-03-12 13:21:00 UTC
I disagree with the patch.

The correct fix is:
  if (allRoutes.size () == 0)
    {
      return;
    }

or, better
  if (allRoutes.empty())
    {
      return;
    }

On the other hand, later the map is traversed with an iterator. Thus removing the if() is not introducing a bug, it's just removing an optimization (it wasn't working anyway right now).

T.
Comment 3 Hemanth Narra 2012-03-17 21:00:57 UTC
Created attachment 1361 [details]
patch to fix bug 1369 in dsdv-routing-protocol.cc

Yes, I agree. we need this if statement. Here is the patch that fixes this bug.
Comment 4 Hemanth Narra 2012-03-17 21:02:48 UTC
Marking this bug as fixed. Daniel, can you please upload this patch to the repository?
Comment 5 Tommaso Pecorella 2012-03-18 07:11:18 UTC
Pushed to changeset 7767 - 657d0877064e