Is MSVC / O2 / Gs0 or / Gs4096 expected?

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.)

0
visual-c ++ visual-studio compiler-options visual-c ++ - 2015
Feb 20 '17 at 11:07
source share

No one has answered this question yet.

See similar questions:

54
What is the difference between the / Ox and / O2 compiler options?

or similar:

485
"At the moment, the breakpoint will not be deleted. The source code is different from the original version." What does it mean?
438
The name "ConfigurationManager" does not exist in the current context
352
The name "InitializeComponent" does not exist in the current context
37
Boost performance with msvc 14.1 (VS2017 RC)
7
Inconsistent behavior of MSVC and GCC with sizeof
5
Is there any way in GCC, Clang, and MSVC to conform to C ++ 98 rather than C ++ 03?
one
Msvc delete partition from binary
0
Can MSVC _penter and _pexit interceptors be disabled for each function?
0
How to check if the compiler options were set correctly in the msvc 2010 c ++ project at compile time?
0
Visual C ++ / HEAP Link Builder



All Articles