Avoid warning for type punning like
author <shinichiro.hamaji@gmail.com> <>
Thu, 30 Jul 2009 10:42:59 +0000 (10:42 +0000)
committer <shinichiro.hamaji@gmail.com> <>
Thu, 30 Jul 2009 10:42:59 +0000 (10:42 +0000)
src/logging_unittest.cc:591: warning: dereferencing type-punned pointer will break strict-aliasing rules

As we'll never dereference the casted pointers, it's OK to silence this warning.

git-svn-id: https://google-glog.googlecode.com/svn/trunk@67 eb4d4688-79bd-11dd-afb4-1d65580434c0

src/logging_unittest.cc

index 77cbe23..76bf31b 100644 (file)
@@ -586,10 +586,10 @@ TEST(CheckNOTNULL, Simple) {
   void *ptr = static_cast<void *>(&t);
   void *ref = CHECK_NOTNULL(ptr);
   EXPECT_EQ(ptr, ref);
-  CHECK_NOTNULL(reinterpret_cast<char *>(&t));
-  CHECK_NOTNULL(reinterpret_cast<unsigned char *>(&t));
-  CHECK_NOTNULL(reinterpret_cast<int *>(&t));
-  CHECK_NOTNULL(reinterpret_cast<int64 *>(&t));
+  CHECK_NOTNULL(reinterpret_cast<char *>(ptr));
+  CHECK_NOTNULL(reinterpret_cast<unsigned char *>(ptr));
+  CHECK_NOTNULL(reinterpret_cast<int *>(ptr));
+  CHECK_NOTNULL(reinterpret_cast<int64 *>(ptr));
 }
 
 TEST(DeathCheckNN, Simple) {