question

infinityeternity avatar image
0 Votes"
infinityeternity asked GuidoFranzke edited

How do I know if Microsoft InitAll Automatic Initialization feature is enabled?

I don't much like an idea that variables will be initialized whether I want it or not. And I can't find any official information/documentation about Microsoft InitAll Automatic Initialization, only a blog post written by Joe Bialek, Microsoft Software Security Engineer. From his post:

InitAll is enabled for the following components:
1. All kernel-mode code (i.e. anything compiled with /KERNEL) in the Windows code repository
2. All Hyper-V code (hypervisor, kernel-mode components, user-mode components)
3. A variety of other projects such as networking related user-mode services

InitAll is implemented in the front-end of the compiler. Any variables that meet the criteria listed above and which are not initialized at declaration will be initialized at declaration by the front-end. One benefit of this approach is that from the optimizer’s perspective, this looks identical to the developer having initialized at declaration in the source code. This means that any optimizations we build to improve performance with InitAll enabled are not InitAll specific, they benefit anyone that initializes at declaration (or before use).

"A variety of other projects" is very vague. I want to know exactly if variables are auto-initialized against my will, maybe against the standard (though I'm not sure about that one, because "indeterminate" that used in the standard doesn't necessarily imply the compiler can't initialize it implicitly).


c++windows-10-security
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AliceYang-MSFT avatar image
0 Votes"
AliceYang-MSFT answered

Hi,

I'm not sure whether this works but you can try. Please run command prompt as administrator then type DISM /online /get-features /format:table | more.

It will display all the list of features enabled or disabled on your computer. Here format:table and more are optional and are used to improve the readability of the features.

If it doesn't work, sorry but I have no solution because I know nothing about C++.


If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GuidoFranzke avatar image
1 Vote"
GuidoFranzke answered GuidoFranzke edited

Hello,
as far as I know, in Debug version all variables are initialized, but in Release version they stay uninitialized. I don't care if auto-initialization is provided by the compiler or not. The developer must handle his variables correctly. When porting the code to another compiler or maybe even after a compiler update, you will or can run into problems if you only rely on compiler-specific features which are not Standard.

If you want to know if your compiler provides auto-initialization, just print out the variable content in your code.

Regards, Guido

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.