https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81767
Bug ID: 81767 Summary: Unused variable warning with structured binding Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- The following code produces "warning: unused variable 'ignore' [-Wunused-variable]": int main() { int m[2][2] = {{1,2}, {3, 4}}; int sum = 0; for (auto& [ignore, value] : m) { sum += value; } return sum - 6; } This is not good, as multiple users would like to ignore part of the result and deal only with the other part. Seems better to warn only if result of structured binding does not used at all: for (auto& [ignore, value] : m) { // "warning: structured binding result not used sum += 0; } Otherwise emit no warning (just like clang does).