fogsong233 wrote:

> I am a bit confused, if the lambda is on the global scope it implicitly 
> captures by reference, right: https://godbolt.org/z/rM1z1xfjq我有点困惑,如果 lambda 
> 在全局作用域中,它会隐式地按引用捕获,对吧:https://godbolt.org/z/rM1z1xfjq
> 
> In that sense I'd think the diagnostic is correct, right?从这个角度来看,我认为诊断是正确的,对吧?

It really depends on how clang-repl defines its execution context. Intuitively, 
we feel like we are working within a function scope (like main), so we 
unconsciously reach for [&] or [&variable] to capture surrounding state. 
However, technically, clang-repl treats these variables as globals to ensure 
persistence, meaning we can access them directly without any capture. The 
diagnostic, therefore, reflects this implementation choice: we perceive it as a 
local context, but the tool defines it as global.

https://github.com/llvm/llvm-project/pull/178579
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to