https://bugzilla.novell.com/show_bug.cgi?id=767522
https://bugzilla.novell.com/show_bug.cgi?id=767522#c1
Richard Guenther
In both 12.1 and Factory. If I compile it with: gcc -D_FORTIFY_SOURCE=2 -O1 -fno-tree-dominator-opts -o test test.c
"Doctor, it hurts when I do this!" well, then don't do it. Fact is that due to -fno-tree-dominator-opts (which would perform constant propagation) when we finally give up and decide that the length argument is not constant, nothing propagates this fact to the conditional and thus we end up with D.3393_19 = 0; // was: __builtin_constant_p (length) if (D.3393_19 != 0) { if (length == 0) __warn_memset_zero_len (); else __builtin_memset (D.3362_7, 255, length); } you simply get what you have asked for - fortification warnigns rely on GCC performing simple optimizations - if you disable those you break their efficiency and get this kind of false positives. To quote the glibc header: /* The first two tests here help to catch a somewhat common problem where the second and third parameter are transposed. This is especially problematic if the intended fill value is zero. In this case no work is done at all. We detect these problems by referring non-existing functions. */ __extern_always_inline void * __NTH (memset (void *__dest, int __ch, size_t __len)) { if (__builtin_constant_p (__len) && __len == 0 && (!__builtin_constant_p (__ch) || __ch != 0)) { __warn_memset_zero_len (); return __dest; } return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest)); } Please never disable selected optimization passes - this kind of disabling does not receive good testing and is likely causing more problems than it helps. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.