Let's say I have the following class:
class A{ };
And then in my code I have a function:
A foo(){ A ret;
And then I use the function later ....
Would an optimizing compiler (e.g. g++ ) simply consider foo() as a void function and skip the actual memory allocation for an empty object? This may not do, because even an empty class has a size of 1.
source share