By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,917 Members | 1,287 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,917 IT Pros & Developers. It's quick & easy.

evaluating builtin [] during initialization

P: n/a
It seems like it would not be hard for the optimizer to generate the
same
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
generated
"pre-main" executable code to initialize y (when it's assinged from
x[1]).

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

Jul 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
posted:

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


Try:

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.