[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/SignlessTypes/cast.cpp

Jeff Cohen jeffc at jolt-lang.org
Fri Apr 6 19:59:54 PDT 2007



Changes in directory llvm-test/SingleSource/UnitTests/SignlessTypes:

cast.cpp updated: 1.2 -> 1.3
---
Log message:

Make it work on 64-bit systems.

---
Diffs of the changes:  (+5 -4)

 cast.cpp |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)


Index: llvm-test/SingleSource/UnitTests/SignlessTypes/cast.cpp
diff -u llvm-test/SingleSource/UnitTests/SignlessTypes/cast.cpp:1.2 llvm-test/SingleSource/UnitTests/SignlessTypes/cast.cpp:1.3
--- llvm-test/SingleSource/UnitTests/SignlessTypes/cast.cpp:1.2	Sat Nov 25 21:41:57 2006
+++ llvm-test/SingleSource/UnitTests/SignlessTypes/cast.cpp	Fri Apr  6 21:59:37 2007
@@ -138,10 +138,11 @@
   
   // Cast of malloc result to another type
   {
-    int* int_ptr = (int*) malloc(sizeof(long));
-    *int_ptr = 42;
-    long* long_ptr = (long*) int_ptr;
-    printf("%ld\n", *long_ptr);
+    // Note: must use volatile, otherwise g++ miscompiles at -O2 (but not LLVM)
+    volatile float* float_ptr = (float*) malloc(sizeof(unsigned));
+    *float_ptr = 10;
+    volatile unsigned* unsigned_ptr = (volatile unsigned*) float_ptr;
+    printf("%x\n", *unsigned_ptr);
   }
 
   // Propagation of single-use casts into other instructions






More information about the llvm-commits mailing list