Bug 59967 - Not Verifiable: Cannot take the address of a init-only field at 0x0002
Summary: Not Verifiable: Cannot take the address of a init-only field at 0x0002
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: Verifier (show other bugs)
Version: master
Hardware: PC Mac OS
: --- enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-04 16:51 UTC by Marek Safar
Modified: 2018-01-05 14:15 UTC (History)
4 users (show)

Tags: bugpool-archive
Is this bug a regression?: ---
Last known good build:


Attachments
output (4.00 KB, application/x-msdownload)
2017-10-04 16:51 UTC, Marek Safar
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 for Bug 59967 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Marek Safar 2017-10-04 16:51:22 UTC
Created attachment 25105 [details]
output

This is a feature request from C# 7.2 Roslyn which has this new "optimization" which breaks peverify. They are aware of it but consider this to be peverify bug/limitation.

With following code

struct S
{
	public enum Type
	{
		Error
	}

	readonly Type type;

	public override string ToString ()
	{
		return type.ToString ();
	}

	public static void Main ()
	{
	}
}

attached .exe is generated with 2.6 csc and peverify fails with

Not Verifiable: Cannot take the address of a init-only field at 0x0002
Comment 1 Rodrigo Kumpera 2017-10-10 23:18:36 UTC
Is there a spec of that change? This sample is not enough to figure out what the new behavior is.
Comment 2 Marek Safar 2017-10-11 12:04:10 UTC
I am not really sure but I asked at https://github.com/dotnet/roslyn/issues/22485

I guess the easiest workaround would be to check for IsReadOnlyAttribute attribute on a struct and alter the checks based on that
Comment 3 Marek Safar 2017-11-21 22:07:03 UTC
This is hurting us on performace we need to run roslyn in legacy IL codegen for BCL builds