[PATCH] D20079: Avoid gcc warning about casting ptr-to-object to ptr-to-fun
Douglas Katzman via llvm-commits
llvm-commits at lists.llvm.org
Mon May 9 19:19:52 PDT 2016
dougk updated this revision to Diff 56656.
dougk added a comment.
fix declaration
http://reviews.llvm.org/D20079
Files:
lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
lib/stats/stats_client.cc
Index: lib/stats/stats_client.cc
===================================================================
--- lib/stats/stats_client.cc
+++ lib/stats/stats_client.cc
@@ -30,11 +30,13 @@
namespace {
-void *LookupSymbolFromMain(const char *name) {
+void (*LookupSymbolFromMain(const char *name))() {
#ifdef _WIN32
- return reinterpret_cast<void *>(GetProcAddress(GetModuleHandle(0), name));
+ return reinterpret_cast<void (*)()>(GetProcAddress(GetModuleHandle(0), name));
#else
- return dlsym(RTLD_DEFAULT, name);
+ void (*f)();
+ *(void**)&f = dlsym(RTLD_DEFAULT, name);
+ return f;
#endif
}
Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
@@ -80,8 +80,8 @@
char *outputBuffer,
size_t *outputBufferSize,
uint32_t flags);
- swift_demangle_ft swift_demangle_f =
- (swift_demangle_ft) dlsym(RTLD_DEFAULT, "swift_demangle");
+ swift_demangle_ft swift_demangle_f;
+ *(void**)&swift_demangle_f = dlsym(RTLD_DEFAULT, "swift_demangle");
if (swift_demangle_f)
return swift_demangle_f(name, internal_strlen(name), 0, 0, 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20079.56656.patch
Type: text/x-patch
Size: 1367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160510/738bab1a/attachment.bin>
More information about the llvm-commits
mailing list