Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When compiling C# sources with mcs it transforms new int into Array.Empty<int>(). This causes problems in code that rightly expects that new-ing a class will return a unique instance.
From the C# spec:
Instances of classes are created using the new operator,
which allocates memory for a new instance,
invokes a constructor to initialize the instance, and
returns a reference to the instance.
As an array is a class it must conform to this spec, and I don't see anything in the spec file that allows the current transformation.
I also haven't seen any version of csc.exe apply this conversion either (including the Roslyn compiler included in mono trunk).
Additionally: I'm currently relying on the fact that doing "new something" returns references for which object.ReferenceEquals() returns false. This transformation invalidates that assumption.
*** Bug 51163 has been marked as a duplicate of this bug. ***
Fixed in master and Mono 4.8
That was quick! Thanks!