[cfe-dev] clang-tidy: Inconsistent chain of reasoning using

Anders Waldenborg via cfe-dev cfe-dev at lists.llvm.org
Sat Sep 21 08:59:39 PDT 2019


Artem Dergachev via cfe-dev writes:
>
> Had a look, thanks! It's one of those nasty pointer cast representation
> bugs:

Hi,

the last few days I've been chasing a false positive in our code base
which I believe is similar to this. I managed to minimize down to:

int hasharray(void **d) {
        void *entries[1];
        entries[0] = d[0];

        char *buf = (char *)entries;
        return buf[1]; // warning: Undefined or garbage value returned to caller
}

clang_analyzer_getExtent of `entries` is 8, whereas for `buf` is it 1.

I find it quite interesting that by changing `entries` to just be a
single pointer rather than an array it works as expected.


Not sure this helps you in any way, but thought it might be good to
share it.

 anders



More information about the cfe-dev mailing list