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

            Bug ID: 61935
           Summary: Missing "unused variable" warning in 4.9 but it was in
                    g++ 4.8
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: galdralag at bk dot ru

In following code (g++ -Wall test.cpp) variable rrr is unused but no warnings
printed.
If I remove destructor in class A then warning occurs.
In g++ 4.8 warning occurs always

//////////////////////////////////////////////////
#include <iostream>

class A
{
public:
   int a;
   virtual ~A(){}
};

class B : public A
{
public:
   int b;
};

void test(A* a)
{
   B& rrr = *static_cast<B*>(a);
   std::cout << "test\n";
}

int main()
{
   B bb;
   test(&bb);
   return 0;
}
//////////////////////////////////////////////////

Reply via email to