[cfe-dev] Warning for unused lambda captures
    Aaron Ballman via cfe-dev 
    cfe-dev at lists.llvm.org
       
    Fri Dec 16 08:14:50 PST 2016
    
    
  
On Fri, Dec 9, 2016 at 7:44 AM, Malcolm Parsons via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> I would like to add a warning for lambdas that explicitly capture
> variables that they don't use.
>
> e.g.
> int i = 3;
> auto f = [&i] { return 5; };
>
> This is similar to Wunused-private-field. I propose the flag
> -Wunused-lambda-capture.
>
> Comments?
I think this could be a useful warning for explicit captures. It seems
possible that someone may want to capture something by value purely
for its RAII properties, but that seems unlikely to be common and
could still be silenced with an explicit cast to void?
~Aaron
> --
> Malcolm Parsons
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
    
    
More information about the cfe-dev
mailing list