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

Fix MSVC workaround with FMT_ENFORCE_COMPILE_STRING #2049

Closed
wants to merge 3 commits into from

Conversation

yeswalrus
Copy link
Contributor

Per comments in #2038, This is just the proper fix for a previous attempt at working around this compile error. Though Microsoft reported that a related error had been resolved (https://developercommunity.visualstudio.com/content/problem/1256077/internal-compiler-failure-with-macro-defining-lamb.html) in the latest build of MSVC, the more complex case is still a problem, which I've reported here: https://developercommunity.visualstudio.com/content/problem/1277597/internal-compiler-c0001-error-on-complex-nested-la.html

@vitaut
Copy link
Contributor

vitaut commented Dec 5, 2020

Could you post a full repro and the error from MSVC for future reference?

@yeswalrus
Copy link
Contributor Author

Full Repro can be achieved by simply disabling this #ifdef. I suspect the error has something to do with the depth of template nesting but wasn't able to narrow down the repro case any further. Full log of what I see locally here:

>------ Build All started: Project: fmt, Configuration: x64-Debug (default) ------
  [1/5] Linking CXX executable bin\posix-mock-test.exe
  [2/5] Building CXX object test\CMakeFiles\enforce-compiletime-test.dir\enforce-compiletime-test.cc.obj
  FAILED: test/CMakeFiles/enforce-compiletime-test.dir/enforce-compiletime-test.cc.obj 
  C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DFMT_ENFORCE_COMPILE_STRING -DFMT_LOCALE -DGTEST_HAS_STD_WSTRING=1 -DGTEST_LANG_CXX11=0 -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 -D_VARIADIC_MAX=10 -I..\..\..\include -I..\..\..\test\gtest -I..\..\..\test\gmock -I..\..\..\test\. /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd /showIncludes /Fotest\CMakeFiles\enforce-compiletime-test.dir\enforce-compiletime-test.cc.obj /Fdtest\CMakeFiles\enforce-compiletime-test.dir\ /FS -c ..\..\..\test\enforce-compiletime-test.cc
C:\dev\yeswalrus\fmt\include\fmt\format.h(3279): fatal error C1001: Internal compiler error.
  (compiler file 'D:\a01\_work\6\s\src\vctools\Compiler\CxxFE\sl\p1\c\symbols.c', line 31449)
   To work around this problem, try simplifying or changing the program near the locations listed above.
  If possible please provide a repro here: https://developercommunity.visualstudio.com 
  Please choose the Technical Support command on the Visual C++ 
   Help menu, or open the Technical Support help file for more information
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1602): note: see reference to function template instantiation 'void fmt::v7::detail::check_format_string<Rep&,S,0>(S)' being compiled
          with
          [
              Rep=__int64,
              S=fmt::v7::detail::format_duration_value::<lambda_0fb45198f1f1e3f7491065cca1733391>::()::FMT_COMPILE_STRING
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1808): note: see reference to function template instantiation 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<wchar_t>,wchar_t>,intmax_t> fmt::v7::make_args_checked<Rep&,S,wchar_t>(const S &,const __int64 &)' being compiled
          with
          [
              Rep=__int64,
              S=fmt::v7::detail::format_duration_value::<lambda_0fb45198f1f1e3f7491065cca1733391>::()::FMT_COMPILE_STRING
          ]
  C:\dev\yeswalrus\fmt\include\fmt/chrono.h(778): note: see reference to function template instantiation 'std::back_insert_iterator<fmt::v7::basic_memory_buffer<wchar_t,500,std::allocator<wchar_t>>> fmt::v7::format_to<OutputIt,fmt::v7::detail::format_duration_value::<lambda_0fb45198f1f1e3f7491065cca1733391>::()::FMT_COMPILE_STRING,Rep&,true>(OutputIt,const S &,Rep &)' being compiled
          with
          [
              OutputIt=std::back_insert_iterator<fmt::v7::basic_memory_buffer<wchar_t,500,std::allocator<wchar_t>>>,
              Rep=__int64,
              S=fmt::v7::detail::format_duration_value::<lambda_0fb45198f1f1e3f7491065cca1733391>::()::FMT_COMPILE_STRING
          ]
  C:\dev\yeswalrus\fmt\include\fmt/chrono.h(1158): note: see reference to function template instantiation 'OutputIt fmt::v7::detail::format_duration_value<Char,_Rep,std::back_insert_iterator<fmt::v7::basic_memory_buffer<wchar_t,500,std::allocator<wchar_t>>>,0>(OutputIt,Rep,int)' being compiled
          with
          [
              OutputIt=std::back_insert_iterator<fmt::v7::basic_memory_buffer<wchar_t,500,std::allocator<wchar_t>>>,
              Char=wchar_t,
              _Rep=__int64,
              Rep=__int64
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1119): note: see reference to function template instantiation 'fmt::v7::detail::buffer_appender<wchar_t> fmt::v7::formatter<Arg,wchar_t,void>::format<Context>(const std::chrono::duration<__int64,std::ratio<1,1>> &,FormatContext &)' being compiled
          with
          [
              Arg=std::chrono::duration<__int64,std::ratio<1,1>>,
              Context=fmt::v7::wformat_context,
              FormatContext=fmt::v7::wformat_context
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1119): note: see reference to function template instantiation 'fmt::v7::detail::buffer_appender<wchar_t> fmt::v7::formatter<Arg,wchar_t,void>::format<Context>(const std::chrono::duration<__int64,std::ratio<1,1>> &,FormatContext &)' being compiled
          with
          [
              Arg=std::chrono::duration<__int64,std::ratio<1,1>>,
              Context=fmt::v7::wformat_context,
              FormatContext=fmt::v7::wformat_context
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1108): note: see reference to function template instantiation 'void fmt::v7::detail::value<Context>::format_custom_arg<T,fmt::v7::formatter<T,wchar_t,void>>(const void *,fmt::v7::basic_format_parse_context<wchar_t,fmt::v7::detail::error_handler> &,Context &)' being compiled
          with
          [
              Context=fmt::v7::wformat_context,
              T=std::chrono::duration<__int64,std::ratio<1,1>>
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1105): note: see reference to function template instantiation 'void fmt::v7::detail::value<Context>::format_custom_arg<T,fmt::v7::formatter<T,wchar_t,void>>(const void *,fmt::v7::basic_format_parse_context<wchar_t,fmt::v7::detail::error_handler> &,Context &)' being compiled
          with
          [
              Context=fmt::v7::wformat_context,
              T=std::chrono::duration<__int64,std::ratio<1,1>>
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1456): note: see reference to function template instantiation 'fmt::v7::detail::value<Context>::value<U>(const T &)' being compiled
          with
          [
              Context=fmt::v7::wformat_context,
              U=std::chrono::duration<__int64,std::ratio<1,1>>,
              T=std::chrono::duration<__int64,std::ratio<1,1>>
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1456): note: see reference to function template instantiation 'fmt::v7::detail::value<Context>::value<U>(const T &)' being compiled
          with
          [
              Context=fmt::v7::wformat_context,
              U=std::chrono::duration<__int64,std::ratio<1,1>>,
              T=std::chrono::duration<__int64,std::ratio<1,1>>
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1566): note: see reference to function template instantiation 'fmt::v7::detail::value<Context> fmt::v7::detail::make_arg<true,Context,fmt::v7::detail::type::custom_type,std::chrono::duration<__int64,std::ratio<1,1>>,0>(const T &)' being compiled
          with
          [
              Context=fmt::v7::wformat_context,
              T=std::chrono::duration<__int64,std::ratio<1,1>>
          ]
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1559): note: while compiling class template member function 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<wchar_t>,wchar_t>,std::chrono::duration<__int64,std::ratio<1,1>>>::format_arg_store(const std::chrono::duration<__int64,std::ratio<1,1>> &)'
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1603): note: see reference to function template instantiation 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<wchar_t>,wchar_t>,std::chrono::duration<__int64,std::ratio<1,1>>>::format_arg_store(const std::chrono::duration<__int64,std::ratio<1,1>> &)' being compiled
  C:\dev\yeswalrus\fmt\include\fmt\core.h(1881): note: see reference to class template instantiation 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<wchar_t>,wchar_t>,std::chrono::duration<__int64,std::ratio<1,1>>>' being compiled
  ..\..\..\test\enforce-compiletime-test.cc(26): note: see reference to function template instantiation 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> fmt::v7::format<ChronoTest_FormatWide_Test::TestBody::<lambda_6ba65e1b6bab98328b07f2c69485565d>::()::FMT_COMPILE_STRING,std::chrono::seconds,wchar_t,0>(const S &,std::chrono::seconds &&)' being compiled
          with
          [
              S=ChronoTest_FormatWide_Test::TestBody::<lambda_6ba65e1b6bab98328b07f2c69485565d>::()::FMT_COMPILE_STRING
          ]
  [3/5] Building CXX object test\CMakeFiles\chrono-test.dir\chrono-test.cc.obj
  FAILED: test/CMakeFiles/chrono-test.dir/chrono-test.cc.obj 

@vitaut
Copy link
Contributor

vitaut commented Dec 8, 2020

Considering that MSVC 2017 is too buggy to support FMT_STRING I don't think it makes sense to enable FMT_ENFORCE_COMPILE_STRING on this compiler. Therefore the workaround is not needed.

@vitaut vitaut closed this Dec 8, 2020
@yeswalrus
Copy link
Contributor Author

This is happening in the latest MSVC, 2019. This is also the only place it fails.

@vitaut
Copy link
Contributor

vitaut commented Dec 12, 2020

This is happening in the latest MSVC, 2019.

That's unfortunate but I don't think the version matters. If MSVC fails in such basic case, it can fail on user code making enabling FMT_ENFORCE_COMPILE_STRING problematic for this compiler.

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

Successfully merging this pull request may close these issues.

2 participants