Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC C++17 build errors #2328

Closed
phprus opened this issue May 30, 2021 · 12 comments
Closed

MSVC C++17 build errors #2328

phprus opened this issue May 30, 2021 · 12 comments

Comments

@phprus
Copy link
Contributor

phprus commented May 30, 2021

Commit: 19d45f4

MSVC 19.16.27045.0 + C++17:

D:\a\fmt\fmt\include\fmt/compile.h(519): error C2131: expression did not evaluate to a constant [D:\a\fmt\build\test\compile-test.vcxproj]

https://github.com/phprus/fmt/runs/2704761925?check_suite_focus=true#step:5:46

and (cmake -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_STANDARD=17 -G "NMake Makefiles" ..\..):

Scanning dependencies of target compile-test
        "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\
MSVC\14.16.27023\bin\HostX86\x86\nmake.exe" -f test\CMakeFiles\compile-test.dir\
build.make /nologo -L                  test\CMakeFiles\compile-test.dir\build
[ 32%] Building CXX object test/CMakeFiles/compile-test.dir/compile-test.cc.obj
        cd F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\build\17\test

        C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\
x86\cl.exe @C:\Users\phprus\AppData\Local\Temp\nm4B84.tmp
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27045 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl   /TP -DFMT_LOCALE -DGTEST_HAS_STD_WSTRING=1 -D_SILENCE_TR1_NAMESPACE_DEPRECA
TION_WARNING=1 -IF:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include
 -IF:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\test\gtest\. /DWIN32
/D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -MD   -std:c++17 /FoCMakeFiles\compile-te
st.dir\compile-test.cc.obj /FdCMakeFiles\compile-test.dir\ /FS -c F:\tmp\fmt\fmt
-19d45f4b312e587da201c05c5b4748740c65f3e8\test\compile-test.cc

compile-test.cc
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/chrono.h(301
): warning C4305: 'specialization': truncation from 'int' to 'bool'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(51
9): error C2131: expression did not evaluate to a constant
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(51
9): note: failure was caused by call of undefined function or one not declared '
constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(51
9): note: see usage of 'compile_test_named_Test::TestBody::<lambda_8d7daa2132c7b
b38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_vie
w<char>'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\test\compile-test.cc(129
): note: see reference to function template instantiation 'auto fmt::v7::detail:
:compile<fmt::v7::detail::named_arg<char,int>,compile_test_named_Test::TestBody:
:<lambda_8d7daa2132c7bb38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING,0>(S)' being
compiled
        with
        [
            S=compile_test_named_Test::TestBody::<lambda_8d7daa2132c7bb38b2944b3
c7aa05a56>::()::FMT_COMPILE_STRING
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(52
0): error C2131: expression did not evaluate to a constant
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(51
9): note: failure was caused by call of undefined function or one not declared '
constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(51
9): note: see usage of 'compile_test_named_Test::TestBody::<lambda_8d7daa2132c7b
b38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_vie
w<char>'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): error C2131: expression did not evaluate to a constant
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: failure was caused by call of undefined function or one not declared '
constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: see usage of 'compile_test_named_Test::TestBody::<lambda_8d7daa2132c7b
b38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_vie
w<char>'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(51
8): note: see reference to function template instantiation 'auto fmt::v7::detail
::compile_format_string<fmt::v7::detail::type_list<fmt::v7::detail::named_arg<ch
ar,int>>,0,0,S>(S)' being compiled
        with
        [
            S=compile_test_named_Test::TestBody::<lambda_8d7daa2132c7bb38b2944b3
c7aa05a56>::()::FMT_COMPILE_STRING
        ]
f:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\format.h(546
): note: see reference to class template instantiation 'fmt::v7::basic_string_vi
ew<char>' being compiled
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
1): error C2131: expression did not evaluate to a constant
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: failure was caused by call of undefined function or one not declared '
constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: see usage of 'compile_test_named_Test::TestBody::<lambda_8d7daa2132c7b
b38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_vie
w<char>'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
2): error C2131: expression did not evaluate to a constant
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: failure was caused by call of undefined function or one not declared '
constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: see usage of 'compile_test_named_Test::TestBody::<lambda_8d7daa2132c7b
b38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_vie
w<char>'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
4): error C2131: expression did not evaluate to a constant
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: failure was caused by call of undefined function or one not declared '
constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(45
0): note: see usage of 'compile_test_named_Test::TestBody::<lambda_8d7daa2132c7b
b38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_vie
w<char>'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(35
3): error C2131: expression did not evaluate to a constant
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(35
4): note: failure was caused by call of undefined function or one not declared '
constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(35
4): note: see usage of 'compile_test_named_Test::TestBody::<lambda_8d7daa2132c7b
b38b2944b3c7aa05a56>::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_vie
w<char>'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/compile.h(51
3): note: see reference to function template instantiation 'auto fmt::v7::detail
::parse_tail<Args,2,0,fmt::v7::detail::text<char>,S>(T,S)' being compiled
        with
        [
            Args=fmt::v7::detail::type_list<fmt::v7::detail::named_arg<char,int>
>,
            S=compile_test_named_Test::TestBody::<lambda_8d7daa2132c7bb38b2944b3
c7aa05a56>::()::FMT_COMPILE_STRING,
            T=fmt::v7::detail::text<char>
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.1
6.27023\include\xstring(481): fatal error C1202: recursive type or function depe
ndency context too complex
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\141
6~1.270\bin\Hostx86\x86\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017
\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '
0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017
\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '
0x2'
Stop.

F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\build\17>

MSVC 19.20.27519.0 + C++17 (cmake -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_STANDARD=17 -G "NMake Makefiles" ..\..):

[  1%] Building CXX object CMakeFiles/fmt.dir/src/format.cc.obj
        C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1420~1.275\bin\HostX86\x86\cl.exe @C:\Users
\phprus\AppData\Local\Temp\nmE960.tmp
Microsoft (R) C/C++ Optimizing Compiler Version 19.20.27519 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

cl   /TP -DFMT_LOCALE -IF:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include /DWIN32 /D_W
INDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -MD   -std:c++17 /FoCMakeFiles\fmt.dir\src\format.cc.obj /FdCMake
Files\fmt.dir\fmt.pdb /FS -c F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\src\format.cc

format.cc
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2180): error C3615: const
expr function 'fmt::v7::detail::parse_width::width_adapter::on_error' cannot result in a constant ex
pression
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2181): note: failure was
caused by call of undefined function or one not declared 'constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2181): note: see usage of
 'fmt::v7::detail::specs_handler<Char>::on_error'
        with
        [
            Char=char
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2279): note: see referenc
e to function template instantiation 'const Char *fmt::v7::detail::parse_width<Char,fmt::v7::detail:
:specs_checker<fmt::v7::detail::specs_handler<Char>>&>(const Char *,const Char *,Handler)' being com
piled
        with
        [
            Char=char,
            Handler=fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handler<char>> &
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\format.h(2690): note: see refere
nce to function template instantiation 'const Char *fmt::v7::detail::parse_format_specs<Char,fmt::v7
::detail::specs_checker<fmt::v7::detail::specs_handler<Char>>&>(const Char *,const Char *,SpecHandle
r)' being compiled
        with
        [
            Char=char,
            SpecHandler=fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handler<char>> &
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt/format-inl.h(2570): note: see re
ference to function template instantiation 'void fmt::v7::detail::vformat_to<char>(fmt::v7::detail::
buffer<char> &,fmt::v7::string_view,fmt::v7::basic_format_args<fmt::v7::format_context>,fmt::v7::det
ail::locale_ref)' being compiled
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2209): error C3615: const
expr function 'fmt::v7::detail::parse_precision::precision_adapter::on_error' cannot result in a con
stant expression
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2210): note: failure was
caused by call of undefined function or one not declared 'constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2210): note: see usage of
 'fmt::v7::detail::specs_handler<Char>::on_error'
        with
        [
            Char=char
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2284): note: see referenc
e to function template instantiation 'const Char *fmt::v7::detail::parse_precision<Char,fmt::v7::det
ail::specs_checker<fmt::v7::detail::specs_handler<Char>>&>(const Char *,const Char *,Handler)' being
 compiled
        with
        [
            Char=char,
            Handler=fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handler<char>> &
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2305): error C3615: const
expr function 'fmt::v7::detail::parse_replacement_field::id_adapter::operator ()' cannot result in a
 constant expression
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2305): note: failure was
caused by call of undefined function or one not declared 'constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2305): note: see usage of
 'fmt::v7::detail::vformat_to::format_handler::on_arg_id'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2353): note: see referenc
e to function template instantiation 'const Char *fmt::v7::detail::parse_replacement_field<Char,Hand
ler&>(const Char *,const Char *,fmt::v7::detail::vformat_to::format_handler&)' being compiled
        with
        [
            Char=char,
            Handler=fmt::v7::detail::vformat_to::format_handler
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\format.h(2699): note: see refere
nce to function template instantiation 'void fmt::v7::detail::parse_format_string<false,char,fmt::v7
::detail::vformat_to::format_handler>(fmt::v7::basic_string_view<char>,Handler &&)' being compiled
        with
        [
            Handler=fmt::v7::detail::vformat_to::format_handler
        ]
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2306): error C3615: const
expr function 'fmt::v7::detail::parse_replacement_field::id_adapter::operator ()' cannot result in a
 constant expression
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2306): note: failure was
caused by call of undefined function or one not declared 'constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2306): note: see usage of
 'fmt::v7::detail::vformat_to::format_handler::on_arg_id'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2307): error C3615: const
expr function 'fmt::v7::detail::parse_replacement_field::id_adapter::operator ()' cannot result in a
 constant expression
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2308): note: failure was
caused by call of undefined function or one not declared 'constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2308): note: see usage of
 'fmt::v7::detail::vformat_to::format_handler::on_arg_id'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2310): error C3615: const
expr function 'fmt::v7::detail::parse_replacement_field::id_adapter::on_error' cannot result in a co
nstant expression
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2311): note: failure was
caused by call of undefined function or one not declared 'constexpr'
F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\include\fmt\core.h(2311): note: see usage of
 'fmt::v7::detail::error_handler::on_error'
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1420~1.275\bin\HostX86\
x86\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\
MSVC\14.20.27508\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\
MSVC\14.20.27508\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

F:\tmp\fmt\fmt-19d45f4b312e587da201c05c5b4748740c65f3e8\build\19>
@vitaut
Copy link
Contributor

vitaut commented May 30, 2021

Seems related to named arguments. Did it work before ca82198? cc @alexezeder

@phprus
Copy link
Contributor Author

phprus commented May 30, 2021

Invalid commit between 7d4c92f (work) and 126c8cb (error).

@phprus
Copy link
Contributor Author

phprus commented May 30, 2021

39c3c4e - Error
e9c1c41 - Work

@vitaut
Copy link
Contributor

vitaut commented May 30, 2021

Thanks for checking. I don't have msvc at hand to investigate but a PR with a workaround if you find one would be welcome. Otherwise we could just disable relaxed constexpr support on problematic msvc version.

@alexezeder
Copy link
Contributor

alexezeder commented May 30, 2021

There is definitely a problem with FMT_USE_CONSTEXPR macro changes for MSVC 19.16, as it fails to create and use string_view at compile-time - https://godbolt.org/z/qdfqPndWa.

Another problem is probably related to changes of handlers, it can be seen on MSVC 19.20 - https://godbolt.org/z/hnqqKnqGx.
But I have no guess what causes it.

@phprus
Copy link
Contributor Author

phprus commented May 30, 2021

Maybe revert commit 39c3c4e?
And add MSVS 2017 + C++17 to CI?

@phprus
Copy link
Contributor Author

phprus commented Jun 1, 2021

If need, I can make and test the PR to reverting the commit 39c3c4e ?

@vitaut
Copy link
Contributor

vitaut commented Jun 1, 2021

I don't think it makes sense to revert. I am OK with disabling constexpr on msvc 2017 since it's kinda mess anyway.

@phprus
Copy link
Contributor Author

phprus commented Jun 1, 2021

After replace:
(FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1920 || \
to:
(FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1910 || \

error on msvc 2017:

cl   /TP -DFMT_LOCALE -D_WIN32_WINNT=0x0601 -If:\...\fmt\src\in
clude /DWIN32 /D_WINDOWS /GR /EHsc /Zc:__cplusplus /arch:SSE2 /Ox /Ob2 /DNDEBUG
/Zi -MD   -std:c++17 /FoCMakeFiles\fmt.dir\src\format.cc.obj /FdCMakeFiles\fmt.d
ir\fmt.pdb /FS -c f:\...\fmt\src\src\format.cc

format.cc
f:\...\fmt\src\include\fmt\core.h(2183): error C3615: constexpr
 function 'fmt::v7::detail::parse_width::width_adapter::on_error' cannot result
in a constant expression
f:\...\fmt\src\include\fmt\core.h(2184): note: failure was caus
ed by call of undefined function or one not declared 'constexpr'
f:\...\fmt\src\include\fmt\core.h(2184): note: see usage of 'fm
t::v7::detail::specs_handler<Char>::on_error'
        with
        [
            Char=char
        ]
f:\...\fmt\src\include\fmt\core.h(2283): note: see reference to
 function template instantiation 'const Char *fmt::v7::detail::parse_width<Char,
fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handler<Char>>&>(const Cha
r *,const Char *,Handler)' being compiled
        with
        [
            Char=char,
            Handler=fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handle
r<char>> &
        ]
f:\...\fmt\src\include\fmt\format.h(2690): note: see reference
to function template instantiation 'const Char *fmt::v7::detail::parse_format_sp
ecs<Char,fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handler<Char>>&>(
const Char *,const Char *,SpecHandler)' being compiled
        with
        [
            Char=char,
            SpecHandler=fmt::v7::detail::specs_checker<fmt::v7::detail::specs_ha
ndler<char>> &
        ]
f:\...\fmt\src\include\fmt/format-inl.h(2570): note: see refere
nce to function template instantiation 'void fmt::v7::detail::vformat_to<char>(f
mt::v7::detail::buffer<char> &,fmt::v7::string_view,fmt::v7::basic_format_args<f
mt::v7::format_context>,fmt::v7::detail::locale_ref)' being compiled
f:\...\fmt\src\include\fmt\core.h(2213): error C3615: constexpr
 function 'fmt::v7::detail::parse_precision::precision_adapter::on_error' cannot
 result in a constant expression
f:\...\fmt\src\include\fmt\core.h(2214): note: failure was caus
ed by call of undefined function or one not declared 'constexpr'
f:\...\fmt\src\include\fmt\core.h(2214): note: see usage of 'fm
t::v7::detail::specs_handler<Char>::on_error'
        with
        [
            Char=char
        ]
f:\...\fmt\src\include\fmt\core.h(2288): note: see reference to
 function template instantiation 'const Char *fmt::v7::detail::parse_precision<C
har,fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handler<Char>>&>(const
 Char *,const Char *,Handler)' being compiled
        with
        [
            Char=char,
            Handler=fmt::v7::detail::specs_checker<fmt::v7::detail::specs_handle
r<char>> &
        ]
f:\...\fmt\src\include\fmt\core.h(2309): error C3615: constexpr
 function 'fmt::v7::detail::parse_replacement_field::id_adapter::operator ()' ca
nnot result in a constant expression
f:\...\fmt\src\include\fmt\core.h(2309): note: failure was caus
ed by call of undefined function or one not declared 'constexpr'
f:\...\fmt\src\include\fmt\core.h(2309): note: see usage of 'fm
t::v7::detail::vformat_to::format_handler::on_arg_id'
f:\...\fmt\src\include\fmt\core.h(2357): note: see reference to
 function template instantiation 'const Char *fmt::v7::detail::parse_replacement
_field<Char,Handler&>(const Char *,const Char *,fmt::v7::detail::vformat_to::for
mat_handler&)' being compiled
        with
        [
            Char=char,
            Handler=fmt::v7::detail::vformat_to::format_handler
        ]
f:\...\fmt\src\include\fmt\format.h(2699): note: see reference
to function template instantiation 'void fmt::v7::detail::parse_format_string<fa
lse,char,fmt::v7::detail::vformat_to::format_handler>(fmt::v7::basic_string_view
<char>,Handler &&)' being compiled
        with
        [
            Handler=fmt::v7::detail::vformat_to::format_handler
        ]
f:\...\fmt\src\include\fmt\core.h(2310): error C3615: constexpr
 function 'fmt::v7::detail::parse_replacement_field::id_adapter::operator ()' ca
nnot result in a constant expression
f:\...\fmt\src\include\fmt\core.h(2310): note: failure was caus
ed by call of undefined function or one not declared 'constexpr'
f:\...\fmt\src\include\fmt\core.h(2310): note: see usage of 'fm
t::v7::detail::vformat_to::format_handler::on_arg_id'
f:\...\fmt\src\include\fmt\core.h(2311): error C3615: constexpr
 function 'fmt::v7::detail::parse_replacement_field::id_adapter::operator ()' ca
nnot result in a constant expression
f:\...\fmt\src\include\fmt\core.h(2312): note: failure was caus
ed by call of undefined function or one not declared 'constexpr'
f:\...\fmt\src\include\fmt\core.h(2312): note: see usage of 'fm
t::v7::detail::vformat_to::format_handler::on_arg_id'
f:\...\fmt\src\include\fmt\core.h(2314): error C3615: constexpr
 function 'fmt::v7::detail::parse_replacement_field::id_adapter::on_error' canno
t result in a constant expression
f:\...\fmt\src\include\fmt\core.h(2315): note: failure was caus
ed by call of undefined function or one not declared 'constexpr'
f:\...\fmt\src\include\fmt\core.h(2315): note: see usage of 'fm
t::v7::detail::error_handler::on_error'
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\141
6~1.270\bin\Hostx86\x86\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017
\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '
0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017
\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '
0x2'
Stop.

The error is similar to the error in msvs 2019 19.20.27519.

@vitaut
Copy link
Contributor

vitaut commented Jun 1, 2021

Worked around in ed2a637.

@vitaut vitaut closed this as completed Jun 1, 2021
@roman-orekhov
Copy link

On MSVC 19 error reporting inside FMT_STRING is cryptic https://godbolt.org/z/xbveGx13x

fmt::print(FMT_STRING("{:>{1}}\n"), "string", 10);

On my machine results in:

error C3615: constexpr function 'fmt::v8::basic_format_parse_context<char,fmt::v8::detail::error_handler>::on_error' cannot result in a constant expression

While gcc is correct:

/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:639:15: error: 'constexpr void fmt::v8::basic_format_parse_context<Char, ErrorHandler>::on_error(const char*) [with Char = char; ErrorHandler = fmt::v8::detail::error_handler]' called in a constant expression
639 | on_error("cannot switch from automatic to manual argument indexing");

@alexezeder
Copy link
Contributor

On MSVC 19 error reporting inside FMT_STRING is cryptic

To be precise, they both say the same thing, but the result is slightly different, so IMHO GCC isn't correct, as well as MSVC isn't incorrect here. 😉

The reason why the output from GCC is better is that it uses code snippets in this case. Snippets help to understand the context. Here is the output without code snippets:

  • GCC

    error: '... on_error ...' called in a constant expression
    note: '... on_error ...' is not usable as a 'constexpr' function because:
    error: call to non-'constexpr' function '... error_handler::on_error ...'
    
  • MSVC

    error C3615: '... on_error' cannot result in a constant expression
    note: failure was caused by call of undefined function or one not declared 'constexpr'
    note: see usage of '... error_handler::on_error'
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants