ARTICLE AD BOX
Look at this program (godbolt):
#include <cstdio> struct Foo { ~Foo() { printf("~Foo\n"); } }; void foo(Foo) { } int main() { foo(Foo()); }Based on my previous question, this program should not materialize the Foo() in main, but just use it as an initializer when calling foo. So there should be only one instance of Foo, the parameter of foo(). However, with MSVC, the code prints
~Foo ~Fooso there were two instances created, supposedly one for the temporary in main, and one for foo()'s parameter (note: with gcc, only one ~Foo line is printed).
Is this standard conformant?
(Note: if I add an empty copy constructor in Foo, then only one ~Foo line is printed).
5
