From 71c8cedacafe700e662c008b65f5064b23426070 Mon Sep 17 00:00:00 2001
From: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Date: Sun, 5 Aug 2018 18:54:01 -0700
Subject: [PATCH 19/39] Fix incompatible aliasing warnings

We aliased functions with different signatures and gcc now correctly
gives warning for that. Originally gcc 5 same code merging feature
caused us to alias more than necessary, but I am not able to reproduce
this problem anymore. So we're now aliasing only compatible functions.
---
 src/libc_override_gcc_and_weak.h |  8 ++++----
 src/tcmalloc.cc                  | 16 ----------------
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/src/libc_override_gcc_and_weak.h b/src/libc_override_gcc_and_weak.h
index 6875164..bb99b69 100644
--- a/src/libc_override_gcc_and_weak.h
+++ b/src/libc_override_gcc_and_weak.h
@@ -126,9 +126,9 @@ void operator delete[](void *p, size_t size) CPP_NOTHROW
 #else /* !ENABLE_SIZED_DELETE && !ENABLE_DYN_SIZED_DELETE */
 
 void operator delete(void *p, size_t size) CPP_NOTHROW
-  ALIAS(tc_delete);
+  ALIAS(tc_delete_sized);
 void operator delete[](void *p, size_t size) CPP_NOTHROW
-  ALIAS(tc_deletearray);
+  ALIAS(tc_deletearray_sized);
 
 #endif /* !ENABLE_SIZED_DELETE && !ENABLE_DYN_SIZED_DELETE */
 
@@ -197,9 +197,9 @@ void operator delete[](void *p, size_t size, std::align_val_t al) CPP_NOTHROW
 #else /* defined(ENABLE_DYN_SIZED_DELETE) */
 
 void operator delete(void *p, size_t size, std::align_val_t al) CPP_NOTHROW
-  ALIAS(tc_delete);
+  ALIAS(tc_delete_sized_aligned);
 void operator delete[](void *p, size_t size, std::align_val_t al) CPP_NOTHROW
-  ALIAS(tc_deletearray);
+  ALIAS(tc_deletearray_sized_aligned);
 
 #endif /* defined(ENABLE_DYN_SIZED_DELETE) */
 
diff --git a/src/tcmalloc.cc b/src/tcmalloc.cc
index 37c1440..b320b30 100644
--- a/src/tcmalloc.cc
+++ b/src/tcmalloc.cc
@@ -1998,9 +1998,6 @@ TC_ALIAS(tc_free);
 // (via ::operator delete(ptr, nothrow)).
 // But it's really the same as normal delete, so we just do the same thing.
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_nothrow(void* p, const std::nothrow_t&) PERFTOOLS_NOTHROW
-#ifdef TC_ALIAS
-TC_ALIAS(tc_free);
-#else
 {
   if (PREDICT_FALSE(!base::internal::delete_hooks_.empty())) {
     tcmalloc::invoke_hooks_and_free(p);
@@ -2008,7 +2005,6 @@ TC_ALIAS(tc_free);
   }
   do_free(p);
 }
-#endif
 
 extern "C" PERFTOOLS_DLL_DECL void* tc_newarray(size_t size)
 #ifdef TC_ALIAS
@@ -2080,33 +2076,21 @@ extern "C" PERFTOOLS_DLL_DECL void* tc_new_aligned_nothrow(size_t size, std::ali
 }
 
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_aligned(void* p, std::align_val_t) PERFTOOLS_NOTHROW
-#ifdef TC_ALIAS
-TC_ALIAS(tc_delete);
-#else
 {
   free_fast_path(p);
 }
-#endif
 
 // There is no easy way to obtain the actual size used by do_memalign to allocate aligned storage, so for now
 // just ignore the size. It might get useful in the future.
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_sized_aligned(void* p, size_t size, std::align_val_t align) PERFTOOLS_NOTHROW
-#ifdef TC_ALIAS
-TC_ALIAS(tc_delete);
-#else
 {
   free_fast_path(p);
 }
-#endif
 
 extern "C" PERFTOOLS_DLL_DECL void tc_delete_aligned_nothrow(void* p, std::align_val_t, const std::nothrow_t&) PERFTOOLS_NOTHROW
-#ifdef TC_ALIAS
-TC_ALIAS(tc_delete);
-#else
 {
   free_fast_path(p);
 }
-#endif
 
 extern "C" PERFTOOLS_DLL_DECL void* tc_newarray_aligned(size_t size, std::align_val_t align)
 #ifdef TC_ALIAS
-- 
1.8.3.1

