[flang-commits] [PATCH] D132594: [flang] Fix msvc 17.3 build.

Michael Kruse via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Aug 24 12:38:21 PDT 2022


Meinersbur created this revision.
Meinersbur added reviewers: MehdiChinoune, klausler, vdonaldson, DavidTruby, sscalpone, tskeith, isuruf.
Meinersbur added a project: Flang.
Herald added subscribers: jdoerfert, pengfei.
Herald added a project: All.
Meinersbur requested review of this revision.

Compile fix for Microsoft Visual Studio 17.3 (msvc 14.33.31629) which regressed from 17.1.

The compile error is:

  llvm-project\flang\lib\Evaluate\fold-integer.cpp(802,41): error C2672: 'invoke': no matching overloaded function found
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\type_traits(1552,19): message : could be 'unknown-type std::invoke(_Callable &&,_Ty1 &&,_Types2 &&...) noexcept(<expr>)'
  llvm-project\flang\lib\Evaluate\fold-integer.cpp(802,41): message : Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Ty1 &&,_Types2 &&...) noexcept(<expr>)'
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\type_traits(1552): message : see declaration of 'std::invoke'
  llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : With the following template arguments:
  llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : '_Callable=int (__cdecl Fortran::evaluate::value::Integer<16,true,16,unsigned short,unsigned int>::* &)(void) const'
  llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : '_Ty1=const Fortran::evaluate::value::Integer<8,true,8,unsigned char,unsigned short> &'
  llvm-project\flang\lib\Evaluate\fold-integer.cpp(490,1): message : '_Types2={}'
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\type_traits(1546,19): message : or       'unknown-type std::invoke(_Callable &&) noexcept(<expr>)'
  C:\Users\meinersbur\src\llvm-project\flang\lib\Evaluate\fold-integer.cpp(802,41): message : 'unknown-type std::invoke(_Callable &&) noexcept(<expr>)': expects 1 arguments - 2 provided

For some reason, msvc thinks that the lambda argument is `Scalar<T>` instead of `Scalar<TI>` as declared. This only happens in nested closures, using a lambda without `[]` arguments makes the problem disappear. Using `auto` instead to automatically derive the type fixes the problem.

I recently updated the version of Visual Studio on flang-x86_64-windows buildbot <https://lab.llvm.org/buildbot/#/builders/172> which since then fails because of this problem. It occasionally failed with 'fatal error C1001: Internal compiler error." internal error which I hoped to fix with an update.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132594

Files:
  flang/lib/Evaluate/fold-integer.cpp


Index: flang/lib/Evaluate/fold-integer.cpp
===================================================================
--- flang/lib/Evaluate/fold-integer.cpp
+++ flang/lib/Evaluate/fold-integer.cpp
@@ -798,7 +798,7 @@
                   "missing case to fold intrinsic function %s", name.c_str());
             }
             return FoldElementalIntrinsic<T, TI>(context, std::move(funcRef),
-                ScalarFunc<T, TI>([&fptr](const Scalar<TI> &i) -> Scalar<T> {
+                ScalarFunc<T, TI>([&fptr](const auto &i) -> Scalar<T> {
                   return Scalar<T>{std::invoke(fptr, i)};
                 }));
           },


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132594.455325.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220824/b5187c4a/attachment.bin>


More information about the flang-commits mailing list