dmpolukhin wrote:

> I have a mixed feeling about whether we should always exclude all coroutines 
> by default or not. When a coroutine has only one `co-operator` and nothing 
> else should be safe to use a reference parameter? Am I wrong?

No, it may not be safe even in case of single co_return because of initial 
coroutine suspend point *before* entering function body. So if the parameter 
passed by reference is used inside coroutine it is not safe [see more 
here](https://en.cppreference.com/w/cpp/language/coroutines.html#:~:text=thus,%20may%20become%20dangling),
 except for the cases when the call is under co_await i.e. it is synchronous 
call.

> So I think to be "on a safe side" I'd suggest a new option "IngoreCoroutines" 
> that will be `true` by default. If A user 100% knows that all references will 
> outlive the coroutine he could set it to `false`. In the option description 
> we could describe why it is not good to disable it as per cppcore-guidlines. 
> Generally speaking, I think it's not _very_ good to implement 
> _recommendations_ of cppcore-guidlines as a must in non-cppcore checks, they 
> should be under a flag.
> 
> I'd be happy to accept your changes with this option, without - I'd want a 
> second opinion from a maintainer.

Let's wait a bit more for maintainer, if no response, I'll add an option and 
this this case we will have a question what should be the default value for the 
option.

https://github.com/llvm/llvm-project/pull/140912
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to