Question

I experience quite annoying side-effect of class/structure padding with Purify. E.g.

struct something {
    int field1;
    char field2;
};

/* ... */

struct something smth, smth2;
smth.field1 = 1;
smth.field2 = 'A';

smth2 = smth;

The last line would highly likely trigger UMR warning saying that 3 bytes of initialized memory are accessed. This is obviously a false positive: there are no user data in the last three bytes of the struct, it's just a padding.

Often the warnings very very quickly fill up log files making it very hard to see the other, real problems.

Does anybody know any way to suppress the false positives?

Was it helpful?

Solution

I have no experience with purify, but perhaps explicitly initialising the first struct removes this warning:

struct something smth = {0};
struct something smth2;

I assume your structs have block scope (not file). If they have file scope the zero initialising is implicit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top