[csmith-dev] testing C++11 struct rules

Arthur O'Dwyer arthur.j.odwyer at gmail.com
Mon May 14 16:37:09 MDT 2012


On Sun, May 13, 2012 at 8:05 AM, John Regehr <regehr at cs.utah.edu> wrote:
>
> Can you think of any non-pessimistic way (dynamic, I mean) to
> figure out which struct fields are touched by a random program?

Isn't this problem very similar to the problem you solved in
"Volatiles are miscompiled, and what to do about it"? Could you use
that "access summary testing" harness to find accesses to non-volatile
struct fields that have not been explicitly accessed?

The first problem would be, how do you know which struct fields it's
okay to access? Well, you could put a header and footer on each of the
autogenerated program's functions:

void p42(struct S p, struct S *r) {
    printf("push: it's okay to access .s and .q in this part of the
access log\n");
    p.s = r->q;  // the access log will record the addresses
read/written by this statement
    printf("pop: .s and .q are off-limits again\n");
}

The second problem would be, can you get this to work for struct
variables that aren't extern globals? That sounds hard to me, but then
I don't know if maybe you already solved that in 2008. Were you only
testing global variables then, too? Local volatiles are kind of silly,
but you'd definitely want this struct-field-access-thing to be able to
work with structs that are on the stack.

-Arthur



More information about the csmith-dev mailing list