This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

a question about code optimization


---------code-----------
vector<int> a;
/*do somthing*/
for(int i = 0; i<a.size(); i++) {
	/* do something*/
}
--------code end--------

my question is:
is it possible that the compiler will transform the code to this:

int __tmp = a.size();
for(int i = 0; i < __tmp; i++) {
	/*do something*/
}

i think it is impoossible,because in size() function, the programmer
can change some global variables, so the compiler could not do that.

if gcc can, could you tell me how?

i am sorry in advance because i am not familiar with the code optimization.
so i do not know how to search the gcc manual and gcc internal manual to find
answer.could anyone tell me how to find this in the manual?or at least give
some keywords?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]