1 minute ago, Shaarigan said:A compiler dosen't "clear" any memory except you are in debug mode on windows for example. Otherwise you have to assume that you always get uninitialized memory anyways. A placement new/new simply places the vtable pointer on top of your object and calls the constructor, anything else is up to your class.
You can do a simple test, just create a new object instance with an int property for simplicity but do not initialize that int. In debug mode on Windows Visual Studio you'll get a zero integer when inspecting the object, in release mode it can be any kind of number due to uninitialized memory
I understand how it works. It's a question of what's sanctioned by the standard. It's not clear to me that the standard specially disallows a compiler from clearing memory during a new operation.
Also I just did the test. It was zero in release mode too, but it doesn't really matter. It's a question of when it clears it. It might clear memory up front not at "new" time. If it's up front it doesn't matter. However if it clears it when you do a new, my program will fail.