Why does this code crash Visual Studio 2015?
Clash Royale CLAN TAG#URR8PPP
Why does this code crash Visual Studio 2015?
For some reason, even so much as typing this into a C# file in Visual Studio is enough to cause it to instantly crash. Why?
unsafe struct node
node* child;
It seems to occur when the IDE would start coloring keywords and the like.
Trying it in TIO spits out csc.exe exited with code 1
which isn't very helpful.
csc.exe exited with code 1
While array declarations in C# are different than in C/C++, the above seems like it should be perfectly valid. Why isn't it, and why does it crash Visual Studio?
My Visual Studio version is 14.0.23107.
VS 2012 produces a compile error:
Cannot take the address of, get the size of, or declare a pointer to a managed type
– LarsTech
Aug 7 at 17:54
Cannot take the address of, get the size of, or declare a pointer to a managed type
VS2017 instantly, immediately closes
– Camilo Terevinto
Aug 7 at 17:55
Ditto LINQPad. StackoverflowException.
– Crowcoder
Aug 7 at 18:00
I found an existing bug: github.com/dotnet/roslyn/issues/24978
– Amy
Aug 7 at 18:22
1 Answer
1
This is a known bug in Roslyn. This bug will affect any version of Visual Studio that uses Roslyn.
If I am interpreting VersionOf.net correctly, the first version of Visual Studio with Roslyn built-in is 2015. Before then, I think it was available only as an extension. So, Visual Studio 2013 and prior should be unaffected.
It's due to be fixed in the milestone 16 release. At this time, that release is not scheduled.
Because this is a bug in Roslyn, you can "get around" it by editing and compiling the code containing the unsafe struct
in an older version of Visual Studio, one that predates Roslyn. Visual Studio 2012 should work. You can then use the resultant .DLL in your current software.
unsafe struct
An unverified fix is available if you build Roslyn yourself from this branch. The fix was made in this commit.
according to this, you're qualifying for step number 3 or 4: meta.stackexchange.com/a/132704/382678 between awesome and legendary.
– Jean-François Fabre
Aug 7 at 19:49
nice move answering this properly: the question is probably in the 10k tools best questions of today. So here comes the 20k ;)
– Jean-François Fabre
Aug 7 at 19:50
@Jean-FrançoisFabre What is "10k tools best questions of today"?
– Amy
Aug 7 at 21:05
stackoverflow.com/tools. This question is indeed #1. seems that I was right :)
– Jean-François Fabre
Aug 7 at 21:06
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Confirmed, I pasted that code into VS2015 and it immediately froze, then crashed 20 seconds later. If you remove the
, it can be safely copied into a VS code window. However, the moment you type the
, VS crashes.
– Amy
Aug 7 at 17:51