C++ 同一套代码使用x64编译和x86得到不同的结果

代码仓库: https://gitee.com/osby/Socket...
要实现的功能及主要代码
模拟Socket接口实现收发数据, 并在收发时前加解密.

#include <iostream>
#include "Encrypt.h"
#include "SocketProtocol.h"
using namespace std;

int main()
{
  char data[512] = { 0 };
  const int len = 10;
  memcpy(data, "1234567890aabbcc", len);
  char receive[512] = { 0 };
  int recLen = 0;
  char encData[512] = { 0 };
  int encLen = 0;

  Encrypt* enc = new Encrypt();
  SocketProtocol* sp = new SocketProtocol();

  int ret;
  ret = enc->encode(data, len, encData, encLen);
  if (0 != ret) {
    printf("enc->encode() err: %d \n ", ret);
    goto End;
  }
  else {
    printf("加密前: %s, 加密后: %s \n", data, encData);
  }

  ret = sp->Init();
  if (0 != ret) {
    printf("->Init() err: %d \n ", ret);
    goto End;
  }

  ret = enc->decode(encData, encLen, receive, recLen);
  if (0 != ret) {
    printf("sp->Send() err: %d \n ", ret);
    goto End;
  }
  else {
    printf("解密前: %s, 解密后: %s \n", encData, receive);
  }

End:
  delete enc;
  delete sp; // 在使用x86编译时, 这条语句会报错

  return 0;
}

使用x86调试报错
image.png

使用x64编译完美通过
image.png

期待大神解惑, 感谢!🙇‍

阅读 2.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题