https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67858
Bug ID: 67858 Summary: g++-5.1.1 warns about unused variable only when optimization flag is used Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: crayzeewulf at gmail dot com Target Milestone: --- Created attachment 36446 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36446&action=edit Code that demostrates the bug. In a large project, I've been getting some compiler warnings from g++-5.1.1 only when building the release version (which uses optimization flags) but not while building the debug version (which disables most compiler optimization). I've narrowed down the problem to a minimal example attached below with commands to reproduce the problem. The problem does not occur if I use g++-4.8.4. This is also discussed on StackOverflow at: http://stackoverflow.com/questions/32917767/g-5-1-1-warns-about-unused-variable-only-when-optimization-flag-is-used