blob: 172f374704bb5566e6f3137ef5ea5eab1751a371 [file] [log] [blame]
// { dg-do run }
// { dg-shouldfail "asan" }
struct IntHolder {
int val;
};
const IntHolder *saved;
void save(const IntHolder &holder) {
saved = &holder;
}
int main(int argc, char *argv[]) {
save({10});
int x = saved->val; // BOOM
return x;
}
// { dg-output "ERROR: AddressSanitizer: stack-use-after-scope on address.*(\n|\r\n|\r)" }
// { dg-output "READ of size 4 at.*" }
// { dg-output ".*'<unknown>' <== Memory access at offset \[0-9\]* is inside this variable.*" }