Visual Studio 2013

时间:2015-11-19 07:38:29

标签: c++ visual-studio

在我的一个类foo中,我将值插入到某个静态成员数组static unsigned int index[9][9][9][9]中,并带有以下内容

for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      for (int k = 0; k < 9; k++) {
        for (int l = 0; l < 9; l++) {
          if (index[i][j][k][l] != 100) {
            setIndex(i, j, k, l, &index[j][i][k][l]);
            setIndex(i, j, k, l, &index[i][j][l][k]);
            setIndex(i, j, k, l, &index[j][i][l][k]);
            setIndex(i, j, k, l, &index[k][l][i][j]);
            setIndex(i, j, k, l, &index[k][l][j][i]);
            setIndex(i, j, k, l, &index[l][k][i][j]);
            setIndex(i, j, k, l, &index[l][k][j][i]);
          }
        }
      }
    }
  }

函数setIndex如下:

void foo::setIndex(int i, int j, int k, int l, unsigned int *p) {
  *p = getIndex(i,j,k,l);
}

它需要

unsigned int foo::getIndex(int i, int j, int k, int l) {
  return index[i][j][k][l];
}

当我尝试在Visual Studio 2013下编译时,我得到了奇怪的内部编译器错误

error MSB6006: "CL.exe" exited with code -1073740940.

或者,有时也是:

fatal error c1001 internal compiler error

现在,如果我只改变我的代码,例如,在第一行:

  int i;
  for (int a = 0; a < 9; a++) {
    i = a;
    [...]
  }

它编译没有问题。

有人能理解问题的根源是什么吗?

这里是我重现它的最小代码:

foo.h中:

class foo{
 public:
  static void setIndexes();
  static unsigned int getIndex(int i, int j, int k, int l);

 private:
  static void setUniqueIndexes();
  static void setIndex(int i, int j, int k, int l, unsigned int *p);
  static unsigned int index[9][9][9][9];
};

Foo.cpp中:

#include "foo.h"

unsigned int foo::index[9][9][9][9];

void foo::setIndexes() {
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      for (int k = 0; k < 9; k++) {
        for (int l = 0; l < 9; l++) {
          index[i][j][k][l] = 100;
        }
      }
    }
  }

  setUniqueIndexes();

  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      for (int k = 0; k < 9; k++) {
        for (int l = 0; l < 9; l++) {
          if (index[i][j][k][l] != 100) {
            setIndex(i, j, k, l, &index[j][i][k][l]);
            setIndex(i, j, k, l, &index[i][j][l][k]);
            setIndex(i, j, k, l, &index[j][i][l][k]);
            setIndex(i, j, k, l, &index[k][l][i][j]);
            setIndex(i, j, k, l, &index[k][l][j][i]);
            setIndex(i, j, k, l, &index[l][k][i][j]);
            setIndex(i, j, k, l, &index[l][k][j][i]);
          }
        }
      }
    }
  }
}

void foo::setIndex(int i, int j, int k, int l, unsigned int *p) {
  *p = getIndex(i,j,k,l);
}

unsigned int foo::getIndex(int i, int j, int k, int l) {
  return index[i][j][k][l];
}

void foo::setUniqueIndexes() {
  index[0][0][0][0] = 0;
}

如果我注释掉函数setIndexes()的前面部分之一,或者如果我删除了setUniqueIndexes()中的语句,它还会编译!

注意:这样的代码没有多大意义,我把它减少到了重现错误的最小值

0 个答案:

没有答案