From 164b87a138cdad99df7c05040c99bc6e316c02c5 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 14 Jul 2016 20:37:31 +0200 Subject: [PATCH 1/1] Fix optimization error with GCC 6.1 With new gcc/g++ version, the memset() call in SMARTALLOC::new() is stripped out automatically with the -O2 flag. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71885 The patch modifies slightly the code to avoid this optimization. --- bacula/src/lib/smartall.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bacula/src/lib/smartall.h b/bacula/src/lib/smartall.h index 61ec9a95db..4c6921174c 100644 --- a/bacula/src/lib/smartall.h +++ b/bacula/src/lib/smartall.h @@ -109,15 +109,13 @@ void *operator new(size_t s, const char *fname, int line) { size_t size = s > sizeof(int) ? (unsigned int)s : sizeof(int); void *p = sm_malloc(fname, line, size); - memset(p, 0, size); - return p; + return memset(p, 0, size); /* return memset() result to avoid GCC 6.1 issue */ } void *operator new[](size_t s, const char *fname, int line) { size_t size = s > sizeof(int) ? (unsigned int)s : sizeof(int); void *p = sm_malloc(fname, line, size); - memset(p, 0, size); - return p; + return memset(p, 0, size); /* return memset() result to avoid GCC 6.1 issue */ } void operator delete(void *ptr) -- 2.39.2