++ i versus i ++: is there any difference in any modern compiler?

Possible duplicate:
Is there a performance difference between I ++ and ++ I'm in C ++?

I understand that:

i++;

It is estimated that more instructions are required than

++i;

Because it generates an intermediate result that you do not need to use, so people put "++ i" in lines of code that are not needed for the intermediate result.

However, compilers are really smart, and they can determine if the result is used or not. They can tell all about things. But they are not magical

So, I'm curious that on modern compilers, does any other option really matter, or is it just compiling with the same machine code?

+3
4

, int. , operator++, .

+9

, (, , , ,...), , (var ++) .

+2

C . , , . ++ , , i, , operator++ , . , .

, . ( , "" )

+1

Visual ++, , :

    i++;

00AB149C  mov         eax,dword ptr [i]  
00AB149F  add         eax,1  
00AB14A2  mov         dword ptr [i],eax  

    ++j;

00AB14A5  mov         eax,dword ptr [j]  
00AB14A8  add         eax,1  
00AB14AB  mov         dword ptr [j],eax  
+1

Source: https://habr.com/ru/post/1792589/


All Articles