Due to a bug that was fixed in C# 4, the following program prints true. (Try it in LINQPad)
void Main() { new Derived(); }
class Base {
public Base(Func<string> valueMaker) { Console.WriteLine(valueMaker()); }
}
class Derived : Base {
string CheckNull() { return "Am I null? " + (this == null); }
public Derived() : base(() ...
I've been scratching my head about this for the last 4 hours, trying out all kinds of little experiments, but I can't seem to figure out what's going wrong. Could this be a compiler bug?
Test.m:
- (id)initWithContentsOfURL:(NSURL *)aURL error:(NSError **)error
{
if (!(self = [super init])) {
return nil;
}
return sel...
I have hit upon a real brain scorcher in C++, it has never happened to me before.
The gist of the problem is that upon invocation of my (template) function the arguments I have defined defaults for have their values scrambled. It only happens if I call the function with the defaults.
My template function is declared like this:
templat...
FINAL EDIT: It does indeed appear to be a compiler bug - see the accepted answer.
Using VBA within Excel 2007, I have the following code in 'Class1':
Option Explicit
Public Function strange(dummy As String, ParamArray pa())
Debug.Print pa(LBound(pa))
End Function
Public Sub not_strange(dummy As String, ParamArray pa())
Debug....
Since I don't know exactly what part of it alone that triggers the error, I'm not entirely sure how to better label it.
This question is a by-product of the SO question c# code seems to get optimized in an invalid way such that an object value becomes null, which I attempted to help Gary with yesterday evening. He was the one that found...