Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace越界导致的报错 #19

Open
MC-dusk opened this issue Jun 11, 2023 · 0 comments
Open

replace越界导致的报错 #19

MC-dusk opened this issue Jun 11, 2023 · 0 comments

Comments

@MC-dusk
Copy link

MC-dusk commented Jun 11, 2023

我自己clone下来make后使用有问题:

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::replace: __pos (which is 4294967295) > this->size() (which is 35)

折腾了一会发现是在替换字符串的时候,判断是否搜索到末尾step != str.npos这个地方有问题。

根据终端的提示和vscode的提示猜测是32和64位的差异导致的问题,vscode悬浮显示:static constexpr inline const size_t std::string::npos = 18446744073709551615Ui64,是2的64次-1,而4294967295是2的32次-1,两者不一样大,判断不到,就会在搜索不到的情况下去replace导致错误。

暂时改成step < str.length()后可用,不过还要chcp 65001换powershell代码页才能不乱码,而且还是不能输入中文theme。


win10 64位专业版
C:\msys64\mingw64\bin\mingw32-make.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant