A variable not detected as not used

前端 未结 3 1964
别那么骄傲
别那么骄傲 2021-01-18 09:41

I am using g++ 4.3.0 to compile this example :

#include 

int main()
{
  std::vector< int > a;
  int b;
}

If I compile

3条回答
  •  深忆病人
    2021-01-18 10:25

    a is not a built-in type. You are actually calling the constructor of std::vector and assigning the result to a. The compiler sees this as usage because the constructor could have side effects.

提交回复
热议问题