Issue 168577
Summary [TySan] Type aliasing violations not detected on returned struct.
Labels new issue
Assignees
Reporter BStott6
    Reproducer (C):
```c
struct S {
    int a;
 float b;
};

struct S returns_s(void) {
    struct S x;
    x.a = 1;
    x.b = 1.0f;
    return x;
}

int main(void) {
    struct S x = returns_s();

    // This should produce an aliasing violation.
    float aliased = *((float *) &x.a);
}
```

When compiled with `clang -fsanitize=type`, the sanitizer does not catch the type aliasing violation reading `x.a` through a float pointer. If `S` is created inline (and its members are assigned explicitly rather than in the constructor - that's a different issue), then the aliasing violation is correctly reported.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to