Thanks to visit codestin.com
Credit goes to github.com

Skip to content

<format>: format("{:a<10}", "") fails STL internal check _First < _Last #4241

@StephanTLavavej

Description

@StephanTLavavej

Found by std/utilities/format/format.functions/vformat.pass.cpp in the upcoming libcxx update. I'm working on a fix.

C:\Temp>type meow.cpp
#include <cassert>
#include <format>
#include <string>
using namespace std;

int main() {
    const string actual = format("{:a<10}", "");
    assert(actual == "aaaaaaaaaa");
}
C:\Temp>cl /EHsc /nologo /W4 /std:c++20 /MTd /Od meow.cpp && meow
meow.cpp

C:\Temp>cl /EHsc /nologo /W4 /std:c++20 /MTd /Od /D_ENABLE_STL_INTERNAL_CHECK meow.cpp && meow
meow.cpp
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!

Program: C:\Temp\meow.exe
File: C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.39.33218\include\format
Line: 244

Expression: STL internal check: _First < _Last

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

---------------------------
Abort   Retry   Ignore   
---------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!formatC++20/23 format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions