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

            Bug ID: 64383
           Summary: missed warning for unused variable.
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pluto at agmk dot net

#include <memory>
#include <vector>

int main()
{
    std::vector< std::shared_ptr< int > > v1;
    v1.push_back( std::make_shared< int >( 7 ) );
    for( auto p : v1 )
    {
    }
    std::vector< int > v2;
    v2.push_back( 7 );
    for( auto i : v2 )
    {
    }
}


the 'p' variable is not reported as unused.


% LANG=C g++ -Wall -g2 t.cpp -o t -std=c++1y
t.cpp: In function 'int main()':
t.cpp:13:15: warning: unused variable 'i' [-Wunused-variable]
     for( auto i : v2 )
               ^

Reply via email to