471,052 Members | 1,274 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,052 software developers and data experts.

evaluating builtin [] during initialization

It seems like it would not be hard for the optimizer to generate the
object code from this source code:

int x[] = { 3, 6, 9 };
int y = x[1];

as it does from this source code:

int x[] = { 3, 6, 9 };
int y = 6;

But it tried two compilers, with optimization enabled, and both
"pre-main" executable code to initialize y (when it's assinged from

Anyone seen a compiler that does optimize out builtin [] in
Or, anyone know why it is hard/bad to optimize [] out?

Jul 5 '06 #1
1 1005

int x[] = { 3, 6, 9 };
int y = x[1];


int const x[] = { 3, 6, 9 };
And see if it makes a difference. (Or have you already tried that, and are
now experimenting with non-const arrays... ?)


Frederick Gotham
Jul 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Stephen Ferg | last post: by
11 posts views Thread by Rangi Keen | last post: by
6 posts views Thread by Anders K. Olsen | last post: by
4 posts views Thread by Pål Andreassen | last post: by
reply views Thread by satishwise | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.