Skip to content

<format>: error C2668 when import <format> as header unit and use std::format_to #1919

Description

Describe the bug
When import <format> as a headerunit, using std::format_to leads to an error C2668 in Release mode.
This problem does not occur in Debug mode.

Command-line test case

D:\cpptest>type repro.cpp
import <format>;
import <string>;

int main()
{
        std::string msg;
        std::format_to(std::back_inserter(msg), "{}", "");
        return 0;
}
D:\cpptest>cl /std:c++20 /permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Zc:inline /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /WX- /Zc:forScope /Gd /Oi /MD /std:c++20  /EHsc /nologo /exportHeader /headerName:angle format string
format
string

D:\cpptest>cl /std:c++20 /permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Zc:inline /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /WX- /Zc:forScope /Gd /Oi /MD /std:c++20  /EHsc /nologo /headerUnit:angle format=format.ifc /headerUnit:angle string=string.ifc repro.cpp /c
repro.cpp
D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.29.30035\include\format(2461): error C2668: 'abs': ambiguous call to overloaded function
D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.29.30035\include\cstdlib(27): note: could be 'float abs(float) noexcept'
D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.29.30035\include\cstdlib(27): note: or       'float abs(float) noexcept'
D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.29.30035\include\format(2461): note: while trying to match the argument list '(const _Float)'
......

Expected behavior
The file should compile successfully.

STL version
Microsoft Visual Studio Enterprise 2019 Preview
Version 16.10.0 Preview 3.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerCompiler work involvedresolvedSuccessfully resolved without a commit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions