Because it is confusing , and MSDN does not help:
The MS C ++ compiler has the /Gs[size] option:
size (optional) The number of bytes that local variables can occupy before running the stack probe. If /Gs is specified without a size argument, this is the same as /Gs0
It also has a default value:
The default value / Gs 4096 allows you to use the Windows application software package to grow correctly at runtime. We recommend that you do not change the default value unless you know exactly why change it.
Which - I can only guess at this point - is used when the no / Gs option is generally specified.
Optimizer /O2 setup then continues:
Parameter :: Equivalent :: Comment
/O2 (Maximize Speed) :: /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy :: Generates the fastest code in most cases. (default setting for release builds)
The list /Gs here, interpreted verbatim, can be interpreted to say that /O2 means /Gs == /Gs0 . However, this does not make much sense to me because / Gs docs state:
/Gs0 activates stack probes for each function call that requires storage for local variables. This can adversely affect performance.
So what I would like to do here is that /O2 actually implies a default value for /Gs4096 .
Given that MSDN docs do not seem to directly affect this, can anyone confirm or deny this? (I haven't done any code-code tests yet, because first I need to figure out which assembly should look like a way to find out the answer.)
visual-c ++ visual-studio compiler-options visual-c ++ - 2015
Martin Ba Feb 20 '17 at 11:07 2017-02-20 11:07
source share