In the following section of code:
if(addr == address)
{
this.cache.Add(entry);
return entry.Name;
}
Looks pretty easy and simple. Problem though is, the return entry.Name
line is only sporadically executed even though it is impossible for an
address match to not occur since I know for a fact the necessary data
is there for it to occur.
What happens instead, the function executes the exception at the end
that happens if it never found an address match.
This ONLY happens in Release mode though!
In Debug mode, everything runs just fine...
To make things wierder, the following code works fine in release mode:
if(addr == address)
{
string a = addr.ToString();
string b = address.ToString();
b = a + b;
if (b == "testing234")
{
MessageBox.Show("blah");
}
this.cache.Add(entry);
return entry.Name;
}
Yes, I know it looks stupid. I know it doesn't make sense (at least to
me). But if I add that totally nonesense string code with the if
statement to make sure the compiler doesn't optimize it out, then the
return line is run everytime.
If someone wants to look at the whole function in its entirety, it is
available at http://www.somrek.net/function.cs
I've never seen anything like this happen before and I don't know if I
actually found some issue or if I am just being braindead. =)
Any ideas or thoughts would be much appreciated!
Thanks,
Stephan