[Ns-bugs] [Bug 1388] LTE module doesn't build in optimized mode with GCC 4.7
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Thu Mar 15 15:13:15 PDT 2012
https://www.nsnam.org/bugzilla/show_bug.cgi?id=1388
--- Comment #3 from Tommaso Pecorella <tommaso.pecorella at unifi.it> 2012-03-15 18:13:15 EDT ---
I'm not happy with the patch... sorry if I'm pedantic.
The problem seems to be more subtle, and silencing the compiler by obfuscating
the code isn't very wise. I have to confess that the compiler is smart indeed,
and it found an obscure vector boundary issue.
while (SpectralEfficiencyForCqiIndex[cqi] < s && cqi <= 14)
{ [...] }
Problem: the check is done sequentially (it's an and), so when cqi is 15 the
first vector will go out of boundaries. The second check will return false and
the while will stop.
A smarter solution is to invert the checks.
while ( cqi <= 14 && SpectralEfficiencyForCqiIndex[cqi] < s )
{ [...] }
This should make the compiler happy again. I can't check, but if the error goes
away, this is way cleaner.
Cheers,
T.
--
Configure bugmail: https://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Ns-bugs
mailing list