Clang warning on global destructor [duplicate]

  c++, clang

Consider the following

// main.cpp
#include <string>
class A {
  std::string s;
};
static A a;
int main() {}

Using clang++ main.cpp -Wglobal-constructors to compile, I get the following warning

main.cpp:6:10: warning: declaration requires a global destructor [-Wglobal-constructors]

My questions are:

  1. What does this warning mean and why does it happen.
  2. How to resolve this warning.

Edit:
I tried to add a destructor ~A() but this warning is still there.

Source: Windows Questions C++

LEAVE A COMMENT