变量未递增在C#中发布的x64 [英] Variable is not incrementing in C# Release x64

查看:185
本文介绍了变量未递增在C#中发布的x64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能向我解释为什么这块code做得很好,当我执行它在x86平台以及它为什么会失败的x64?

结果:

  • 86调试:12345678910
  • 64调试:12345678910
  • 86版:12345678910
  • 64版:1111111111

如果我改变的东西,如消除未使用的变量之一,如果我删除无用的循环p_lFirstId ++后,奇怪的行为消失了。

我发现改变PDB,只有在我发布配置为满时,它再次的工作。

如果你直接从Visual Studio运行code,它做的很好了。

这是一个JIT编译器错误?

感谢你在前进。

 类节目
{
    静态无效的主要(字串[] args)
    {
        测试(NULL,NULL,NULL,0,1);
    }

    公共静态无效测试(
        名单<字符串>清单当然,列表和LT;字符串> unused1,
        串unused2,INT unused3,长p_lFirstId)
    {
        清单当然=新的名单,其中,串>();

        StringBuilder的sbSql =新的StringBuilder();

        的for(int i = 0;我小于10;我++)
        {
            sbSql.Append(p_lFirstId);
            p_lFirstId ++;

            的foreach(在清单当然串sColonne)
            {

            }

        }

        的System.Console.WriteLine(sbSql.ToString());
    }
}
 

解决方案

这是在CLR的错误。我劝联系微软,并要求他们纠正他们的下一个版本中,此缺陷。

Could someone explain to me why this piece of code is doing well when I execute it on a x86 platform and why it fail on x64 ?

Results :

  • x86 Debug : 12345678910
  • x64 Debug : 12345678910
  • x86 Release : 12345678910
  • x64 Release : 1111111111

If I change something, like removing one of the unused variables, or if I remove the useless for-loop after p_lFirstId++, the strange behavior disappear.

I found that changing "pdb-only" to "full" in my release configuration, it's work again.

If you run the code directly from visual studio, it's doing well too.

Is this a JIT Compiler bug ?

Thank you in advance.

class Program
{
    static void Main(string[] args)
    {
        Test(null, null, null, 0, 1);            
    }

    public static void Test(
        List<string> liste, List<string> unused1,
        string unused2, int unused3, long p_lFirstId)
    {
        liste = new List<string>();

        StringBuilder sbSql = new StringBuilder();

        for (int i = 0 ; i < 10 ; i++)
        {
            sbSql.Append(p_lFirstId);
            p_lFirstId++;                

            foreach (string sColonne in liste)
            {

            }

        }

        System.Console.WriteLine(sbSql.ToString());
    } 
}

解决方案

This is a bug in the CLR. I would advise contacting Microsoft and asking them to correct this bug in their next release.

这篇关于变量未递增在C#中发布的x64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆