INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# local pointers with an EXPLICIT lower bound

## local pointers with an EXPLICIT lower bound

(OP)
I have tried to test my code and confronted with st strange:
making local pointers with an EXPLICIT lower bound seems to generate faster code.
Is this right? In case it is, why?

### RE: local pointers with an EXPLICIT lower bound

Have you looked at the code generation?

### RE: local pointers with an EXPLICIT lower bound

(OP)
Sorry, could you explain what do you mean by code generation and how I can look at that?

### RE: local pointers with an EXPLICIT lower bound

Depends on the compiler - some compilers will generate an assembler listing if requested to do so. You can then compare the ones with and without the lower bound.

Alternatively, in the debugger, set a breakpoint where the code is accessing an array index and have a look at the disassembly.

At a guess, if you specify a lower bound of 0, it will be faster (since it is easier to compute arrays from a 0 index). If it is any other lower bound, the speed will be the same.

### RE: local pointers with an EXPLICIT lower bound

Just to clarify - say there are 3 arrays

integer a(-5:5), b(0:10), c(11)

And there are 3 computations

a(2) = 10
b(2) = 10
c(2) = 10

To compute the index

addr(b(2)) = addr(b) + (2 - (0)) * size(integer) optimized to b + 2 * size(integer)

The computation of b has one instruction less so in theory, it will be faster.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!