Update ChangeLog and version files for release
[official-gcc.git] / gcc / testsuite / c-c++-common / tsan / free_race.c
blob258f7b7420dfe0b6685839a7b070b56e3aab5b92
1 /* { dg-shouldfail "tsan" } */
3 #include <stdlib.h>
5 void __attribute__((noinline)) foo(int *mem) {
6 free(mem);
9 void __attribute__((noinline)) bar(int *mem) {
10 mem[0] = 42;
13 int main() {
14 int *mem =(int*)malloc (100);
15 foo(mem);
16 bar(mem);
17 return 0;
20 /* { dg-output "WARNING: ThreadSanitizer: heap-use-after-free.*(\n|\r\n|\r)" } */
21 /* { dg-output " Write of size 4 at.* by main thread:(\n|\r\n|\r)" } */
22 /* { dg-output " #0 bar.*(\n|\r\n|\r)" } */
23 /* { dg-output " #1 main.*(\n|\r\n|\r)" } */
24 /* { dg-output " Previous write of size 8 at.* by main thread:(\n|\r\n|\r)" } */
25 /* { dg-output " #0 free.*(\n|\r\n|\r)" } */
26 /* { dg-output " #\(1|2\) foo.*(\n|\r\n|\r)" } */
27 /* { dg-output " #\(2|3\) main.*(\n|\r\n|\r)" } */