"for" statement issue
    Steven Schveighoffer via Digitalmars-d 
    digitalmars-d at puremagic.com
       
    Fri Oct 21 07:47:05 PDT 2016
    
    
  
On 10/21/16 10:28 AM, Kagamin wrote:
> On Friday, 21 October 2016 at 14:16:26 UTC, Steven Schveighoffer wrote:
>> How about in general forbidding lambda statements that aren't called
>> or used anywhere?
>
> How?
>
> int main()
> {
>     int a;
>     auto b = ()=>{a++;};
>     b();
>     assert(a==1);
>     return 0;
> }
Oh, I see. This error that I didn't see right away wouldn't be 
prevented, but that's not what I was talking about. I just meant that 
the original problem shouldn't have happened, since the lambda is never 
used.
I totally agree that the above sucks and should be fixed.
-Steve
    
    
More information about the Digitalmars-d
mailing list