wierdness in debugger

Enigma via Digitalmars-d-ide digitalmars-d-ide at puremagic.com
Thu Mar 30 10:28:44 PDT 2017


When debugging a foreach loop that works on an enum constant, the 
debugger has different behavior if the loop uses brackets or not

The following should demonstrate it:

import std.meta, std.algorithm, std.stdio;
void main()
{
	enum X = AliasSeq!(1,2,3,4,5,3,2,1);
	int y = 0;	
	foreach(x; X)
	   y = max(x, y);
	
	writeln(y);
	
	y = 0;
	foreach(x; X)
	{
	   y = max(x, y);
	}
	
	
	writeln(y);	
}

a BP on the writeln lines will have the debugger skip to the 
writeln when stepping in the first case and not the second.

It's as if the debugger thinks that the statement after the first 
max is part of the for each block or something weird like that. 
Was confusing at first and thought it was a bug because I was 
getting the wrong value for y. When, in fact, the BP on the 
writeln simply did not execute the foreach loop completely like 
it would in the second case, even though it should.



More information about the Digitalmars-d-ide mailing list