comparison gcc/testsuite/g++.dg/warn/Wreturn-local-addr-6.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* PR c/90737 - inconsistent address of a local converted to intptr_t
2 between callee and caller
3 { dg-do compile }
4 { dg-options "-O1 -Wall -Wreturn-local-addr -fdump-tree-optimized" } */
5
6 typedef __INTPTR_TYPE__ intptr_t;
7
8 const intptr_t&
9 return_addr_label_as_intref (void)
10 {
11 label:
12 if ((const intptr_t*)&&label == 0)
13 __builtin_exit (1);
14
15 return *(const intptr_t*)&&label; // { dg-warning "\\\[-Wreturn-local-addr]" } */
16 }
17
18 const intptr_t&
19 return_addr_local_as_intref (void)
20 {
21 int a[1];
22 if ((const intptr_t*)a == 0)
23 __builtin_exit (1);
24
25 return (const intptr_t&)a; // { dg-warning "\\\[-Wreturn-local-addr]" } */
26 }
27
28 /* Verify that the return value has been replaced with zero:
29 { dg-final { scan-tree-dump-times "return 0;" 2 "optimized" } } */