Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

ULP advisor - what's the reasoning behind ULP rule 14.1?

$
0
0

Hi,

I've been looking at the set of rules checked by the ULP advisor and there's one that I'm a little unsure about. Rule 14.1 says "Use unsigned variables for indexing":

short arr[8] = {0, 1, 2, 3, 4, 5, 6, 7};
unsigned short ia = 0;
short ib = 0;
arr[ia] = 12; // No complaints from ULP advisor
arr[ib] = 44; // ULP advisor warns of rule 14.1

What's the reasoning behind this rule? I haven't spotted anything to suggest that indexed mode addressing is slower with a signed index. Is it due to the fact that array indexing is often accompanied by index range checks, and only the upper limit needs to be checked for unsigned values when the valid range is [0,N]?


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>