Re: Unjustified warning?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The warning isn't caused by the explicit memset but rather by GCC
introducing one within the loop.  I'm not sure that the warning
itself should be considered a bug.  If the function is called with
length greater than or equal to 32 it will overflow.  So I'd say
the warning is helpful in pointing it out.  What's not helpful
is the missing location information, compounded by the fact that
the only memset call in the source code isn't what causes it.

To avoid the warning make sure foo() calls avx_memzero with
a length of at most the size of bar.

Thank you for the clarification. If I limit the length as in the code attached, I still get the warning however.

Best regards,
Marcel

#include <immintrin.h>
#include <string.h>
#include <algorithm>

long long bar[2];

void avx_memzero(void* dest, size_t length)
{
	__m256i* d = (__m256i*)dest;
	__m256i s = _mm256_setzero_si256();
	while (length >= 32)
	{
		_mm256_storeu_si256(d++, s);
		length -= 32;
	}
	if (length)
		memset((void*)d, 0, length);
}

void foo(size_t t)
{
	avx_memzero(bar, std::max(sizeof(bar), t));
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux