static object destructor

Hi all,

why both static object destructors and global ones are called after exit from main().

please explain

thank you,
Standard wrote:
3.6.3 Termination [basic.start.term]
1 Destructors (12.4) for initialized objects (that is, objects whose lifetime (3.8) has begun) with static storage duration are called as a result of returning from main and as a result of calling std::exit (18.5).
Standard wrote:
3.7.1 Static storage duration [basic.stc.static]
1 All variables which do not have dynamic storage duration, do not have thread storage duration, and are not local have static storage duration. The storage for these entities shall last for the duration of the program (3.6.2, 3.6.3).

Global object have static storage duration as do local variables or class members declared with static keyword
Topic archived. No new replies allowed.