[Lldb-commits] [PATCH] Host: Fix a pointer-to-function to void-pointer cast

David Majnemer david.majnemer at gmail.com
Tue Jul 22 14:06:52 PDT 2014


Hi zturner, tfiala,

reinterpret_cast may not convert a pointer-to-function to a
void-pointer.  Take a detour through intptr_t and *then* convert to a
pointer-to-function.

This silences a warning emitted by GCC when building LLDB.

http://reviews.llvm.org/D4631

Files:
  source/Host/common/Host.cpp

Index: source/Host/common/Host.cpp
===================================================================
--- source/Host/common/Host.cpp
+++ source/Host/common/Host.cpp
@@ -1057,7 +1057,8 @@
             static ConstString g_lldb_so_dir;
             if (!g_lldb_so_dir)
             {
-                FileSpec lldb_file_spec (Host::GetModuleFileSpecForHostAddress ((void *)Host::GetLLDBPath));
+                FileSpec lldb_file_spec(Host::GetModuleFileSpecForHostAddress(
+                    reinterpret_cast<void *>(reinterpret_cast<intptr_t>(Host::GetLLDBPath))));
                 g_lldb_so_dir = lldb_file_spec.GetDirectory();
                 if (log)
                     log->Printf("Host::GetLLDBPath(ePathTypeLLDBShlibDir) => '%s'", g_lldb_so_dir.GetCString());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4631.11785.patch
Type: text/x-patch
Size: 774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140722/cdbc06a8/attachment.bin>


More information about the lldb-commits mailing list