Giter VIP home page Giter VIP logo

Comments (8)

nanoric avatar nanoric commented on May 18, 2024 1

Maybe I forgot to pull updated code. The test passed. Everything works fine for now.

from scnlib.

nanoric avatar nanoric commented on May 18, 2024

It seems all the code should run correctly under Release mode.
But under Debug mode, whenever you operate an iterator with another one, such as

auto raw = "123456";
std::string_view s(raw);
std::string_view s(raw+2);
s.begin() - s2.begin();  // _STL_VERIFY fails:
/*
code in xstring:
    _NODISCARD constexpr difference_type operator-(const _String_view_iterator& _Right) const noexcept {
#if _ITERATOR_DEBUG_LEVEL >= 1
        _STL_VERIFY(_Mydata == _Right._Mydata && _Mysize == _Right._Mysize,
            "cannot subtract incompatible string_view iterators");
        return static_cast<difference_type>(_Myoff - _Right._Myoff);
#else // ^^^ _ITERATOR_DEBUG_LEVEL >= 1 ^^^ // vvv _ITERATOR_DEBUG_LEVEL == 0 vvv
        return _Myptr - _Right._Myptr;
#endif // _ITERATOR_DEBUG_LEVEL
    }

*/

MSVC will check if s and s2 points to the same buffer and have the same size. If not, exception is thrown.
Thus, the ranges intenally used by scn is not compatible with MSVC's std::string_view under Debug mode. Because write_return function will construct a new ranges(std::string_view), making all operators for iterator invalid.

from scnlib.

eliaskosunen avatar eliaskosunen commented on May 18, 2024

Aw bugger, it's those MSVC debug iterators again. I'll look into this on ~Monday, once I have access to a Windows PC.

from scnlib.

eliaskosunen avatar eliaskosunen commented on May 18, 2024

Fixed in 5b2eb91. Thanks for reporting!

from scnlib.

nanoric avatar nanoric commented on May 18, 2024

MSVC under Debug mode still not work.
The test string_view.cpp fails.
image
image

from scnlib.

nanoric avatar nanoric commented on May 18, 2024

It seems that under MSVC debug mode(_ITERATOR_DEBUG_LEVEL >=1), you must change the range recursively after calling write_return.

from scnlib.

nanoric avatar nanoric commented on May 18, 2024

How can I re-open this issue?
Or should I create a new issue?

from scnlib.

eliaskosunen avatar eliaskosunen commented on May 18, 2024

I can't get that assertion to fire on my Windows PC nor on Appveyor. Can you see if it does for you after 8b3ab27?

from scnlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.