Skip to content

<regex>: basic_regex wants regex_traits to provide things not required by [re.req] #995

Open
@AlexGuteniev

Description

@AlexGuteniev

Describe the bug
basic_regex relies on non-standard extensions of regex_traits

Command-line test case

d:\Temp2>type repro.cpp
#include <array>
#include <iostream>
#include <regex>

struct custom_traits : private std::regex_traits<char>
{
        using base_t = std::regex_traits<char>;

        using base_t::regex_traits;

        using base_t::char_type;
        using base_t::locale_type;
        using base_t::string_type;
        using base_t::char_class_type;

        using base_t::length;
        using base_t::translate;
        using base_t::translate_nocase;
        using base_t::transform;
        using base_t::transform_primary;
        using base_t::lookup_collatename;
        using base_t::lookup_classname;
        using base_t::isctype;
        using base_t::value;
        using base_t::imbue;
        using base_t::getloc;

#ifdef WORKAROUND
        using base_t::_Ch_upper;
        using base_t::_Uelem;
        using base_t::_Ch_alpha;
#endif
};

int main()
{
        std::basic_regex<char, custom_traits> r("3");
        return 0;
}

d:\Temp2>cl /EHsc /W4 /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.cpp
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\regex(3975): error C2247: 'std::_Regex_traits_base::_Ch_upper' not accessible because 'custom_traits' uses 'private' to inherit from 'std::regex_traits<char>'
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\regex(238): note: see declaration of 'std::_Regex_traits_base::_Ch_upper'
.\repro.cpp(5): note: see declaration of 'custom_traits'
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\regex(393): note: see declaration of 'std::regex_traits<char>'
c:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.27.29009\include\regex(3964): note: while compiling class template member function 'bool std::_Parser<_FwdIt,_Elem,_RxTraits>::_CharacterClassEscape(bool)'
** a lot of more errors **

d:\Temp2>cl /EHsc /W4 /WX /DWORKAROUND .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29009.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.cpp
Microsoft (R) Incremental Linker Version 14.27.29009.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:repro.exe
repro.obj

Expected behavior
Should compile without workaround.
May compile or not compile with workaround,

STL version

Microsoft Visual Studio Professional 2019 Preview
Version 16.7.0 Preview 3.1

Additional context
This item is also tracked on Developer Community as DevCom-322328 and by Microsoft-internal VSO-673897 / AB#673897.

vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregexmeow is a substring of homeowner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions