https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69723

            Bug ID: 69723
           Summary: Inconsistent report of unused and uninitialized
                    variables
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: developm...@faf-ltd.com
  Target Milestone: ---

It is here described:
http://stackoverflow.com/questions/35269414/gcc-does-not-warn-variable-set-but-not-used


auto foo() -> void
{
    int unused = 0;
    unused++;
}

and

auto foo() -> void
{
    int x;
    int unused;
    for ( ; x < 100; x++ )  unused++;
}

do not generate and warnings. Only the -O1 generates an error. I expect
error: variable ‘unused’ set but not used [-Werror=unused-but-set-variable].
error: ‘unused’ and ‘x’ are used uninitialized [-Werror=uninitialized]

Reply via email to