>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? Thanks, Jay.
On Nov 13, 2009, at 5:07 AM, Jay Foad wrote:>> 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. -Chris
Apparently Analagous Threads
- [PATCH] convert_windows: uninstall Parallels Tools on first boot
- [PATCH] v2v: recognize Virtuozzo tools as Parallels tools
- [PATCH 0/2] v2v: uninstall the VMware Tools from Windows guests
- [PATCH 1/2] v2v: windows: factor uninstall commands search
- [PATCH v3 15/22] v2v: windows: Convert the Windows-related conversion modules from Str to PCRE.