[llvm-commits] [llvm] r83401 - /llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
Jeffrey Yasskin
jyasskin at google.com
Tue Oct 6 12:06:17 PDT 2009
Author: jyasskin
Date: Tue Oct 6 14:06:16 2009
New Revision: 83401
URL: http://llvm.org/viewvc/llvm-project?rev=83401&view=rev
Log:
Fix illegal cross-type aliasing. Found by baldrick on a newer gcc.
Modified:
llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=83401&r1=83400&r2=83401&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Tue Oct 6 14:06:16 2009
@@ -99,9 +99,8 @@
// Get the pointer to the native code to force it to JIT the function and
// allocate space for the global.
- void (*F1Ptr)();
- // Hack to avoid ISO C++ warning about casting function pointers.
- *(void**)(void*)&F1Ptr = JIT->getPointerToFunction(F1);
+ void (*F1Ptr)() =
+ reinterpret_cast<void(*)()>((intptr_t)JIT->getPointerToFunction(F1));
// Since F1 was codegen'd, a pointer to G should be available.
int32_t *GPtr = (int32_t*)JIT->getPointerToGlobalIfAvailable(G);
@@ -115,9 +114,8 @@
// Make a second function identical to the first, referring to the same
// global.
Function *F2 = makeReturnGlobal("F2", G, M);
- // Hack to avoid ISO C++ warning about casting function pointers.
- void (*F2Ptr)();
- *(void**)(void*)&F2Ptr = JIT->getPointerToFunction(F2);
+ void (*F2Ptr)() =
+ reinterpret_cast<void(*)()>((intptr_t)JIT->getPointerToFunction(F2));
// F2() should increment G.
F2Ptr();
More information about the llvm-commits
mailing list