Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Is pointer aliasing a problem if the pointers are the same?

$
0
0

Hi,

consider this functions intended for vectorization:

void AddSqr(float* restrict dst, float* restrict src, int cnt)
{
for (int i=0; i<cnt; i++) dst[i] = src[i] * src[i];
};

This would work if the src & dst are not aliased of course. But what if src == dst? Extreme cases such as src == dst+1 are not allowed of course. But if the pointers are the same, there shouldn't be a problem, or am I missing something?


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>