Skip to main content
added 887 characters in body
Source Link
blabb
  • 16.7k
  • 1
  • 15
  • 30
  1. always post text instead of screen shots as much as possible .

  2. always provide context .

  3. the compilers , operating systems , architectures , headers everything evolve and what might have been correct yesterday might not be correct today .

  4. code with all warnings and analysis enabled as much as possible .

  5. provide a readily compilable code for some one to spend a few minutes trying to answer if you don't include headers most wont be bothered to look for them .

6) do you know your return statement has a problem called NRVO some compilers will spit cant return n+n2 named returns are not supported ?

use scopes with {} make it a habit .

and not to nitpick but printf is not c++.

i have attached a gif below that should answer your question watch it several times test and edit your question what you do not understand in that gif and whether you were able to find the answer you were looking for by watching it

enter image description here

As Commented there are several kinds of Optimization
you can read the docs for the compiler you use
for msvc cl.exe these are the Optimizations that can be performed

C:\>cl /nologo  /? | grep /O
/O1 maximum optimizations (favor space) /O2 maximum optimizations (favor speed)
/Ob<n> inline expansion (default n=0)   /Od disable optimizations (default)
/Og enable global optimization          /Oi[-] enable intrinsic functions
/Os favor code space                    /Ot favor code speed
/Ox optimizations (favor speed)

optimized code is difficult to analyze
that is why there debug build are used when writing code
optimized builds are used when releasing the code
while releasing the symbols are also stripped away so an optimized release built binary is just bytes all over which the reverse engineer has to decipher

  1. always post text instead of screen shots as much as possible .

  2. always provide context .

  3. the compilers , operating systems , architectures , headers everything evolve and what might have been correct yesterday might not be correct today .

  4. code with all warnings and analysis enabled as much as possible .

  5. provide a readily compilable code for some one to spend a few minutes trying to answer if you don't include headers most wont be bothered to look for them .

6) do you know your return statement has a problem called NRVO some compilers will spit cant return n+n2 named returns are not supported ?

use scopes with {} make it a habit .

and not to nitpick but printf is not c++.

i have attached a gif below that should answer your question watch it several times test and edit your question what you do not understand in that gif and whether you were able to find the answer you were looking for by watching it

enter image description here

  1. always post text instead of screen shots as much as possible .

  2. always provide context .

  3. the compilers , operating systems , architectures , headers everything evolve and what might have been correct yesterday might not be correct today .

  4. code with all warnings and analysis enabled as much as possible .

  5. provide a readily compilable code for some one to spend a few minutes trying to answer if you don't include headers most wont be bothered to look for them .

6) do you know your return statement has a problem called NRVO some compilers will spit cant return n+n2 named returns are not supported ?

use scopes with {} make it a habit .

and not to nitpick but printf is not c++.

i have attached a gif below that should answer your question watch it several times test and edit your question what you do not understand in that gif and whether you were able to find the answer you were looking for by watching it

enter image description here

As Commented there are several kinds of Optimization
you can read the docs for the compiler you use
for msvc cl.exe these are the Optimizations that can be performed

C:\>cl /nologo  /? | grep /O
/O1 maximum optimizations (favor space) /O2 maximum optimizations (favor speed)
/Ob<n> inline expansion (default n=0)   /Od disable optimizations (default)
/Og enable global optimization          /Oi[-] enable intrinsic functions
/Os favor code space                    /Ot favor code speed
/Ox optimizations (favor speed)

optimized code is difficult to analyze
that is why there debug build are used when writing code
optimized builds are used when releasing the code
while releasing the symbols are also stripped away so an optimized release built binary is just bytes all over which the reverse engineer has to decipher

Source Link
blabb
  • 16.7k
  • 1
  • 15
  • 30

  1. always post text instead of screen shots as much as possible .

  2. always provide context .

  3. the compilers , operating systems , architectures , headers everything evolve and what might have been correct yesterday might not be correct today .

  4. code with all warnings and analysis enabled as much as possible .

  5. provide a readily compilable code for some one to spend a few minutes trying to answer if you don't include headers most wont be bothered to look for them .

6) do you know your return statement has a problem called NRVO some compilers will spit cant return n+n2 named returns are not supported ?

use scopes with {} make it a habit .

and not to nitpick but printf is not c++.

i have attached a gif below that should answer your question watch it several times test and edit your question what you do not understand in that gif and whether you were able to find the answer you were looking for by watching it

enter image description here