[LLVMbugs] [Bug 10714] New: Static const initializer not being initialized causing linking to fail (Spec 9.4.2.3)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Aug 20 21:57:57 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10714

           Summary: Static const initializer not being initialized causing
                    linking to fail (Spec 9.4.2.3)
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: rouzier+o at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


The following code fails to linking
=========================================
#include <iostream>

static const int a[] = {0,1,2,3,4,5,6,7,8};

template<int... Numbers> struct int_array;

template<int... Numbers>
struct int_array {
  int x;
  const static int list[] = {Numbers...};
  static void print() {
    for (const int x : list) {
        std::cout << x <<std::endl;
    }
  }
  static void print2() {
    for (const int x : a) {
        std::cout << x <<std::endl;
    }
  }
};

typedef int_array<0,1,2,3,4,5,6,7,8> array_of_ints;

int main (int argc, const char * argv[])
{
  array_of_ints::print();
  array_of_ints::print2();
  return 0;
}
==================================================
Error
Undefined symbols for architecture x86_64:
"__ZN9int_arrayIJLi0ELi1ELi2ELi3ELi4ELi5ELi6ELi7ELi8EEE4listE", referenced
from: __ZN9int_arrayIJLi0ELi1ELi2ELi3ELi4ELi5ELi6ELi7ELi8EEE5printEv in
cc-JDTbNl.o ld: symbol(s) not found for architecture x86_64

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list