无法在类 'POINTER_REGS' 中找到溢出的寄存器(可能是编译器错误)

unable to find a register to spill in class 'POINTER_REGS' (maybe compiler bug)

本文关键字:寄存器 错误 溢出 编译器 POINTER REGS      更新时间:2023-10-16

问题是此代码不会使用avr-g++编译器进行编译。它在标题中产生了错误。当您注释掉第15行或第16行时,它将编译。如果从第15行和第16行的右侧删除"colorArray"或"lackArray",它将进行编译。如果将第15行和第16行的"greyDiff"分别替换为变量赋值的右侧。如果它不在for循环中,它确实会编译。这不是编译器的错误吗?

float colourArrayL[3] = {0, 0, 0};
float whiteArrayL[3] = {0, 0, 0};
float blackArrayL[3] = {0, 0, 0};
float colourArrayR[3] = {0, 0, 0};
float whiteArrayR[3] = {0, 0, 0};
float blackArrayR[3] = {0, 0, 0};
void setup()
{
  for (byte i = 0; i < 3; i++) 
  {
    float greyDiffL = whiteArrayL[i] - blackArrayL[i]; //the highest possible return minus the lowest returns the area for values in between
    float greyDiffR = whiteArrayR[i] - blackArrayR[i];
    colourArrayL[i] = (colourArrayL[i] - blackArrayL[i]) / greyDiffL;
    colourArrayR[i] = (colourArrayR[i] - blackArrayR[i]) / greyDiffR;
  }
}
void loop() {};

我一直在使用avr-g++(GCC)4.8.1,在为自定义类rgbscenario00编写复制构造函数时也有类似的经验。在复制构造函数内复制5个以上rgbled对象时显示错误。我通过添加2个私有方法(使用diver&conquest)解决了这个问题。因此,编译器似乎试图使用所有寄存器,当它们都被使用时,它会以错误停止。这是我的解决方案(只显示重要部分:)

void rgbscenario00::copyrgb123( const rgbscenario00& orig ) {
    magenta         = orig.magenta;
    rood            = orig.rood;
    geel            = orig.geel;
}   
void rgbscenario00::copyrgb456( const rgbscenario00& orig ) {
    groen           = orig.groen;
    blauw           = orig.blauw;
    oranje          = orig.oranje; 
    // uncommenting this last oranje line resulted in
    // "error: unable to find a register to spill 
    // in class 'POINTER_REGS'  "
}
rgbscenario00::rgbscenario00(const rgbscenario00& orig) {
    // I have to split up this copy constructor to avoid 
    // getting a very silly error on the lack of registers
    copyrgb123( orig );
    copyrgb456( orig );
    //magenta = orig.magenta; rood  = orig.rood;  geel = orig.geel;
    //groen   = orig.groen;   blauw = orig.blauw;
    //oranje  = orig.oranje; 
    // uncommenting this oranje line resulted in  
    // "error: unable to find a register to spill 
    // in class 'POINTER_REGS'  "
    inputString         = orig.inputString;
    stringComplete      = orig.stringComplete;
    iteller             = orig.iteller;
    huedeviation        = orig.huedeviation;
    lumdeviation        = orig.lumdeviation;
    uiteller            = orig.uiteller;
    ujchosen            = orig.ujchosen;
    usbspeed            = orig.usbspeed;
    currentmillis       = orig.currentmillis;
    prevmillis          = orig.prevmillis;
    millisperloop       = orig.millisperloop;
    millisperstep       = orig.millisperstep;
    tfuture             = orig.tfuture;
    tstep               = orig.tstep;
    copyboolarray(&(computed[0]),&(orig.computed[0]),maxuirgblednum );
    copyboolarray(&(done[0]),    &(orig.done[0]),    maxuirgblednum );  
    copyuliarray( &(nexttime[0]),&(orig.nexttime[0]),maxuirgblednum );
    copyuiarray(&(uilumvalues[0]),&(orig.uilumvalues[0]),
                maxuilumvalues );
}