This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/523: static object never destructed



>Number:         523
>Category:       c++
>Synopsis:       static object never destructed
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 11 05:36:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Thomas Kunert
>Release:        gcc version 2.96 20000911 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
// This program prints "con", i.e. 
// the destructor of B::a is never called

#include <iostream>

struct A {
    void f(){};
    A(){ std::cout << "con" << endl; }
    ~A(){ std::cout << "des" << endl;}
};

template<class T>
struct B {
    B(){ a.f(); }
    static A a;
};

template <class T> A B<T>::a;

int main()
{
    B<int> b;
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]