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