This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c++/13915] New: Initialization of static template members


#include <iostream>

template<typename T>
struct wrap {
  static T joe;
};

template<typename T>

T wrap<T>::joe;
struct call_out {
  int num;
  call_out() : num(77) {}
};

template<typename T>
struct check_call {
  check_call() {
    std::cout << wrap<T>::joe.num << std::endl;
  }
};

check_call<call_out> x;

int main(){}

should print 77, I think, by 14.7.1/1, which says says:
                                                                               
                                                 
"... in particular, the initialization (and any associated side effects)
of a static data member does not occur unless the static data member is
itself used in a way that requires the definition of the static data
member to exist."

-- 
           Summary: Initialization of static template members
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: japple at freeshell dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: linux x86


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13915


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