From: Eric Bollengier Date: Thu, 14 Jul 2016 18:37:31 +0000 (+0200) Subject: Fix optimization error with GCC 6.1 X-Git-Tag: Release-7.4.3~8 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=164b87a138cdad99df7c05040c99bc6e316c02c5;p=bacula%2Fbacula 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. --- 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)