Exit-time destructor warning in Clang

Source: Internet
Author: User

When writing C + +, if the front end is Clang then when you define a static global variable, a warning may appear called "Exit-time destructor".

As a habit of warning as the wrong look of the year, I determined to find out why this, and the result is this:

A global static variable calls its destructor after the program exits. Why not call it after the program exits? Because if the variable is destroyed during program execution, subsequent operations on that variable can cause a crash.

And the cost of destroying it after exiting is that it will cause the program to quit longer. And this warning is for you to point this out.

Exit-time destructor warning in Clang

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.