Skip to content

replace越界导致的报错 #19

@MC-dusk

Description

@MC-dusk

我自己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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions