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