Weird MSCV error on Compiler Explorer for a peculiar combination of Win line break and split view

141 Views Asked by At

Take this relatively small sample code which uses Range-v3 do define a function that returns a std::vector<std::string> splitting the input std::string on any of \n or \r\n line breaks.¹

#include <cassert>
#include <iostream>
#include <range/v3/algorithm/for_each.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/split.hpp>
#include <range/v3/view/transform.hpp>
#include <range/v3/view/join.hpp>
#include <string>
#include <vector>

using namespace ranges;
using namespace ranges::views;
using namespace std::literals;

std::vector<std::string> splitOSAgnostic(const std::string& str) {
    std::vector<std::string> result;
    for_each(
        str | split("\r\n"s) | transform(split("\n"s)) | join,
        [&result](auto snippet_view) {
            auto documentSnippet = snippet_view | to<std::string>;
            result.push_back(documentSnippet);
        });
    return result;
}

int main() {
    auto res = splitOSAgnostic("a = 1;\nb = 2;\r\nc = 3;\n"s);
    assert(res[0] == "a = 1;"s);           // ^^---- if I remove this,
    assert(res[1] == "b = 2;"s);           // everything is fine
    assert(res[2] == "c = 3;"s);
}

On Compiler Explorer I get the following error:

example.cpp
<source> : fatal error C1083: Cannot open compiler generated file: 'C:\Users\ContainerAdministrator\AppData\Local\Temp\compiler-explorer-compiler2023110-17256-1pb5efl.2aus\output.s.obj': Permission denied
Compiler returned: 1

What am I facing?

Needless to say that Clang and GCC are happy with the code.


(¹) I haven't used regexes for other reasons, but the question is not related to that.

0

There are 0 best solutions below