This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug debug/78265] New: Excess emission of debug info for ODR used global variables


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78265

            Bug ID: 78265
           Summary: Excess emission of debug info for ODR used global
                    variables
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dblaikie at gmail dot com
  Target Milestone: ---

ODR used global (& static class member) variables that are ODR used but never
actually referenced by live code still produce debug info. eg:

extern int i;
inline int f() {
  return i;
}

Even though f is never called, 'i' still gets a debug info description.

If that's insufficiently compelling, consider this case (this turns up in
something like protobuf code repeatedly, as does the above example (look at how
protobufs emit default instances for the above example, the below example comes
up in some similar code I don't think I have a good public example of))

template <typename T>
struct foo {
  static const int i = -1;
  int f() { return i; /* replace this with "return -1;" */ }
};
template<typename T>
const int foo<T>::i;

struct bar {
  foo<int> f;
  int b() {
    return f.f();
  }
};

If you make the suggested substitution, no debug info is produced for this code
at all. As-is, it produces 110 byte CU (this is, of course, actually unbounded
& worse than 110 bytes in the real world case - because once you pull in the
variable, you pull in its type and then any types they need, etc).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]