Variable declared in code but doesn't exist in memory
Although you have fixed the immediate issue by disabling optimization (which proves that it was being optimized out), consider what would happen down the road if you need to optimize the code. You will likely have forgotten about this, and change the settings. Or, someone else might come and change it, or maybe you create a project with new settings.

The best approach, as Chris said, is to declare that variable volatile. This tells the compiler that the variable may be modified in an ISR and prevents the compiler from removing it.

One little word can save you a lot of headaches down the road.