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