Too easy to run out of local variables space
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=3243
Reported by Martin Stjernholm mast@roxen.com
I encountered a case where I got the compilation error "Too many local variables", which I think is due to suboptimal allocation of local variables.
I have a test macro which looks approximately like this:
#define TEST_DET_NOP(RX) do { \
int flags = RX->fsa->flags; \
RX->fsa->determinize(); \
if (RX->fsa->flags != flags) \
error ("Didn't expect a change in the flags.\n"); \
} while (0)
I then have a large function containing many tests that uses this macro. When the function became sufficiently large I got the "Too many local variables" error, apparently because all the flag variables in the macro expansions got their own storages in the frame.
The compiler ought to do sufficient range analysis of variables in local block scopes to be able to reuse the same storage here.