【问题标题】:Garbage value error: The left operand of '^' is a garbage value垃圾值错误:“^”的左操作数是垃圾值
【发布时间】:2022-06-14 02:00:02
【问题描述】:

我正在用 C++ 实现我的代码,但收到 [core.UndefinedBinaryOperatorResult] 的错误。我的代码是:

static result bits(int nm, int xc, int8_t *bt, int8_t *byt)
{

    int64_t tot = 0;
    result ze;

    if (xc == 1) {
        for (int i = 0; i < nm; i++) {
            tot += bt[i];
        }
    } else {
        for (int i = 0; i < nm; i += xc) {

            int8_t z = byt[i] ^ byt[i + 1];
            tot += bt[i] + ((bt[i + 1] ^ z) - z);
        }
    }
    ze.ze = int8_t(std::abs(tot) * 2));

    return ze;
}

错误在一行:

int8_t z = byt[i] ^ byt[i + 1];

请指导我,过去几天我一直陷入此错误,但无法修复它。谢谢

【问题讨论】:

  • 你想使用^作为力量吗?还是按位异或?

标签: c++ debugging clang garbage


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-07
  • 1970-01-01
  • 1970-01-01
  • 2013-07-10
相关资源
最近更新 更多