Issue 176292
Summary [LifetimeSafety] lifetime annotation suggestion and inference does not work with `-std=c++23` or `-std=c++26`
Labels new issue
Assignees
Reporter SidneyCogdill
    https://godbolt.org/z/fPefGroxn

With `-std=c++23 -Werror=experimental-lifetime-safety -Werror=experimental-lifetime-safety-cross-tu-suggestions -Wexperimental-lifetime-safety-intra-tu-suggestions -Xclang -fexperimental-lifetime-safety -Xclang -fexperimental-lifetime-safety-inference`:

```
ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 0
```

With `-std=c++20 -Werror=experimental-lifetime-safety -Werror=experimental-lifetime-safety-cross-tu-suggestions -Wexperimental-lifetime-safety-intra-tu-suggestions -Xclang -fexperimental-lifetime-safety -Xclang -fexperimental-lifetime-safety-inference`:

```
<source>:3:9: warning: parameter in intra-TU function should be marked [[clang::lifetimebound]] [-Wexperimental-lifetime-safety-intra-tu-suggestions]
    3 | auto id(auto a) { return a; }
      |         ^~~~~~
      | [[clang::lifetimebound]]
<source>:9:13: note: in instantiation of function template specialization 'id<int *>' requested here
    9 |         p = id(&a);
      |             ^
<source>:3:26: note: param returned here
 3 | auto id(auto a) { return a; }
      | ^
<source>:9:17: error: object whose reference is captured does not live long enough [-Werror,-Wexperimental-lifetime-safety-permissive]
    9 | p = id(&a);
      |                 ^
<source>:10:5: note: destroyed here
   10 |     }
      |     ^
<source>:11:20: note: later used here
 11 |     auto result = *p;
      |                    ^
1 warning and 1 error generated.
Compiler returned: 1
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to