1 //===-- main.cpp ------------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // I made this example after noting that I was unable to display an unsized 11 // static class array. It turns out that gcc 4.2 will emit DWARF that correctly 12 // describes the PointType, but it will incorrectly emit debug info for the 13 // "g_points" array where the following things are wrong: 14 // - the DW_TAG_array_type won't have a subrange info 15 // - the DW_TAG_variable for "g_points" won't have a valid byte size, so even 16 // though we know the size of PointType, we can't infer the actual size 17 // of the array by dividing the size of the variable by the number of 18 // elements. 19 20 #include <stdio.h> 21 22 typedef struct PointType 23 { 24 int x, y; 25 } PointType; 26 27 class A 28 { 29 public: 30 static PointType g_points[]; 31 }; 32 33 PointType A::g_points[] = 34 { 35 { 1, 2 }, 36 { 11, 22 } 37 }; 38 39 static PointType g_points[] = 40 { 41 { 3, 4 }, 42 { 33, 44 } 43 }; 44 45 int 46 main (int argc, char const *argv[]) 47 { 48 const char *hello_world = "Hello, world!"; 49 printf ("A::g_points[1].x = %i\n", A::g_points[1].x); // Set break point at this line. 50 printf ("::g_points[1].x = %i\n", g_points[1].x); 51 printf ("%s\n", hello_world); 52 return 0; 53 } 54