dodgy use of c_str()

From llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp:

void DebugInfo::EmitGlobalVariable(GlobalVariable *GV, tree decl) {
  // Gather location information.
  expanded_location Loc = expand_location(DECL_SOURCE_LOCATION(decl));
  DIType TyD = getOrCreateType(TREE_TYPE(decl));
  const char *DispName = GV->getNameStr().c_str();

Isn't this use of c_str() dodgy, because the temporary string returned
by Gv->getNameStr() will be destroyed at the end of the expression, so
it's no longer valid to use the memory pointed to by DispName?


Yes, absolutely. Devang, please take a look when you get a chance. This should use getName() with StringRef.