[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Q: Unused local variables


Does having unused local variables in a method actually have an effect?

I've never worried about it until today. My theory is that the only effect would be the execution of the command to allocate some space on the local heap when the method is activated, which would then be freed when the method exits. That is, approximately 1 malloc and 1 free.

But is this what actually happens? Or since the variable is unused is the compiler smart enough to ignore it altogether?

regards

b


Follow-Ups:
Re: Q: Unused local variablesBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>