You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
here is a simple csharp program for triggering the issue:
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args){}
public char GetID(int value)
{
char toRet = ' ';
switch (value)
{
case 1:
toRet = 'a';
break;
case 4:
default:
toRet = 'b';
break;
}
return toRet;
}
}
}
Here is the error message:
Severity Code Description Project File Line Suppression State
Error MSB4018 The "Translate" task failed unexpectedly.
IL2C.InvalidProgramSequenceException: Invalid opcode: Method=ConsoleApp1.Program.GetID(System.Int32), OpCode=switch, Offset=11
at IL2C.AssemblyPreparer.d__1.MoveNext() in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 64
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.<SelectManyIterator>d__172.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.OrderedEnumerable1.<GetEnumerator>d__1.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)
at IL2C.AssemblyPreparer.PrepareMethodBody(IPrepareContext prepareContext, IMethodInformation method) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 134
at IL2C.AssemblyPreparer.PrepareMethod(IPrepareContext prepareContext, IMethodInformation method) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 256
at IL2C.AssemblyPreparer.<>c__DisplayClass5_0.b__4(<>f__AnonymousType12 <>h__TransparentIdentifier0) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 310 at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)
at IL2C.AssemblyPreparer.Prepare(TranslateContext translateContext, Func2 predictType, Func2 predictMethod) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 305
at IL2C.AssemblyPreparer.Prepare(TranslateContext translateContext) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 320
at IL2C.SimpleDriver.Translate(TextWriter logw, CodeTextStorage storage, Boolean readSymbols, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, String assemblyPath) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 39
at IL2C.SimpleDriver.TranslateAll(TextWriter logw, String outputPath, Boolean readSymbols, Boolean enableCpp, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, IEnumerable`1 assemblyPaths) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 121
at IL2C.SimpleDriver.TranslateAll(TextWriter logw, String outputPath, Boolean readSymbols, Boolean enableCpp, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, String[] assemblyPaths) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 142
at IL2C.Translate.Execute() in D:\PROJECT\IL2C\IL2C.Tasks\Translate.cs:line 86
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() ConsoleApp1 C:\Users\damon.peng.nuget\packages\il2c.build\0.4.113\build\IL2C.Build.targets 19
here is the il2c.build version: .4.113
The text was updated successfully, but these errors were encountered:
pengzeshan
changed the title
switch statement issues invalid opcode=swtich
switch statement issues invalid opcode=switch
Sep 27, 2021
cyborgyn
added a commit
to cyborgyn/IL2C
that referenced
this issue
Oct 13, 2021
here is a simple csharp program for triggering the issue:
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args){}
public char GetID(int value)
{
char toRet = ' ';
switch (value)
{
case 1:
toRet = 'a';
break;
case 4:
default:
toRet = 'b';
break;
}
return toRet;
}
}
}
Here is the error message:
Severity Code Description Project File Line Suppression State
Error MSB4018 The "Translate" task failed unexpectedly.
IL2C.InvalidProgramSequenceException: Invalid opcode: Method=ConsoleApp1.Program.GetID(System.Int32), OpCode=switch, Offset=11
at IL2C.AssemblyPreparer.d__1.MoveNext() in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 64
at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.<SelectManyIterator>d__17
2.MoveNext()at System.Linq.Buffer
1..ctor(IEnumerable
1 source)at System.Linq.OrderedEnumerable
1.<GetEnumerator>d__1.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector)at IL2C.AssemblyPreparer.PrepareMethodBody(IPrepareContext prepareContext, IMethodInformation method) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 134
at IL2C.AssemblyPreparer.PrepareMethod(IPrepareContext prepareContext, IMethodInformation method) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 256
at IL2C.AssemblyPreparer.<>c__DisplayClass5_0.b__4(<>f__AnonymousType1
2 <>h__TransparentIdentifier0) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 310 at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable
1 source, Func2 keySelector, Func
2 elementSelector)at IL2C.AssemblyPreparer.Prepare(TranslateContext translateContext, Func
2 predictType, Func
2 predictMethod) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 305at IL2C.AssemblyPreparer.Prepare(TranslateContext translateContext) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\AssemblyPreparer.cs:line 320
at IL2C.SimpleDriver.Translate(TextWriter logw, CodeTextStorage storage, Boolean readSymbols, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, String assemblyPath) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 39
at IL2C.SimpleDriver.TranslateAll(TextWriter logw, String outputPath, Boolean readSymbols, Boolean enableCpp, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, IEnumerable`1 assemblyPaths) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 121
at IL2C.SimpleDriver.TranslateAll(TextWriter logw, String outputPath, Boolean readSymbols, Boolean enableCpp, Boolean enableBundler, TargetPlatforms targetPlatform, DebugInformationOptions debugInformationOptions, String[] assemblyPaths) in C:\cygwin\home\damon.peng\workspace\workForCH\dotNet\IL2C\IL2C.Core\SimpleDriver.cs:line 142
at IL2C.Translate.Execute() in D:\PROJECT\IL2C\IL2C.Tasks\Translate.cs:line 86
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() ConsoleApp1 C:\Users\damon.peng.nuget\packages\il2c.build\0.4.113\build\IL2C.Build.targets 19
here is the il2c.build version: .4.113
The text was updated successfully, but these errors were encountered: