Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

base64 not work well on vc2019 #17

@a645162

Description

@a645162

Expression: cannot seek string iterator after end

The program is normal under the clang compiler, but on vc2019, Microsoft will report an error on the judgment condition of your "for" statement. If the judgment of the maximum pointer of the iterator exceeds the error, the debug channel will report an error, and the output of the Release channel will be abnormal.
Assuming the string length is "length", then it is normal when you execute begin+length<end, but after each round of the loop, the pointer is shifted back by 3 bits, then begin+length+1<end and begin+length+2<end two judgment statements will report an error.

I have a solution:
Change
for (auto it = begin; it < end; it += 3) {
to

auto length = end - begin;
for (auto i = 0; i < length; i += 3) {
				auto it = begin + i;

Change

if (it + 1 < end) {
if (it + 2 < end) {

to

if (i + 1 < length) {
if (i + 2 < length) {

Personally think this is the easiest solution.

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