<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64473>64473</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] Compiler error on Windows with mingw64
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          waj334
      </td>
    </tr>
</table>

<pre>
    When compiling on Windows using mingw64, I get the following error:
```
FAILED: tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/LLVMIRConversionGen.cpp.obj
C:\mingw-64\bin\c++.exe -DEXPENSIVE_CHECKS -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -D_DEBUG -D_FILE_OFFSET_BITS=64 -D_GLIBCXX_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/Users/waj33/Projects/sigo/build/llvm-build/tools/mlir/tools/mlir-tblgen -IC:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/tools/mlir-tblgen -IC:/Users/waj33/Projects/sigo/build/llvm-build/include -IC:/Use
rs/waj33/Projects/sigo/thirdparty/llvm-project/llvm/include -IC:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/include -IC:/Users/waj33/Projects/sigo/build/llvm-build/tools/mlir/include -Wa,-mbig-obj -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noex
cept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections  -O2 -DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/LLVMIRConversionGen.cpp.obj -MF tools\mlir\tools\mlir-tblgen\CMakeFiles\mlir-tblgen.dir\LLVMIRConversionGen.cpp.obj.d -o tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/LLVMIRConversionGen.cpp.obj -c C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
In file included from C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/debug/debug.h:141,
 from C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/stl_algobase.h:69,
 from C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/stl_uninitialized.h:63,
 from C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/memory:69,
 from C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/llvm/include/llvm/Support/Casting.h:20,
 from C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/include/mlir/Support/LLVM.h:24,
 from C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/include/mlir/Support/LogicalResult.h:12,
 from C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp:14:
C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/debug/functions.h: In instantiation of 'bool __gnu_debug::__foreign_iterator_aux3(const _Safe_iterator<_Iterator, _Sequence, _Category>&, const _InputIterator&, const _InputIterator&, std::__true_type) [with _Iterator = __gnu_cxx::__normal_iterator<const long long int*, std::__cxx1998::vector<long long int, std::allocator<long long int> > >; _Sequence = std::__debug::vector<long long int>; _Category = std::random_access_iterator_tag; _InputIterator = llvm::detail::SafeIntIterator<long long int, false>]':
C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/debug/functions.h:164:37: required from 'bool __gnu_debug::__foreign_iterator_aux2(const _Safe_iterator<_Iterator, _Sequence, _Category>&, const _InputIterator&, const _InputIterator&) [with _Iterator = __gnu_cxx::__normal_iterator<const long long int*, std::__cxx1998::vector<long long int, std::allocator<long long int> > >; _Sequence = std::__debug::vector<long long int>; _Category = std::random_access_iterator_tag; _InputIterator = llvm::detail::SafeIntIterator<long long int, false>]'
C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/debug/functions.h:186:28: required from 'bool __gnu_debug::__foreign_iterator_aux(const _Safe_iterator<_Iterator, _Sequence, _Category>&, _InputIterator, _InputIterator, std::__false_type) [with _Iterator = __gnu_cxx::__normal_iterator<const long long int*, std::__cxx1998::vector<long long int, std::allocator<long long int> > >; _Sequence = std::__debug::vector<long long int>; _Category = std::random_access_iterator_tag; _InputIterator = llvm::detail::SafeIntIterator<long long int, false>]'
C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/debug/functions.h:198:36: required from 'bool __gnu_debug::__foreign_iterator(const _Safe_iterator<_Iterator, _Sequence, _Category>&, _InputIterator, _InputIterator) [with _Iterator = __gnu_cxx::__normal_iterator<const long long int*, std::__cxx1998::vector<long long int, std::allocator<long long int> > >; _Sequence = std::__debug::vector<long long int>; _Category = std::random_access_iterator_tag; _InputIterator = llvm::detail::SafeIntIterator<long long int, false>]'
C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/debug/vector:626:4: required from 'std::__debug::vector<_Tp, _Allocator>::iterator std::__debug::vector<_Tp, _Allocator>::insert(const_iterator, _InputIterator, _InputIterator) [with _InputIterator = llvm::detail::SafeIntIterator<long long int, false>; <template-parameter-2-2> = void; _Tp = long long int; _Allocator = std::allocator<long long int>; iterator = std::__debug::vector<long long int>::iterator; const_iterator = std::__debug::vector<long long int>::const_iterator]'
C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/llvm/include/llvm/ADT/STLExtras.h:2015:11: required from 'void llvm::append_range(Container&, Range&&) [with Container = std::__debug::vector<long long int>; Range = iota_range<long long int>]'
C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp:214:17: required from here
C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/debug/functions.h:110:61: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'llvm::detail::SafeIntIterator<long long int, false>::value_type' {aka 'long long int'}
  110 |       return __foreign_iterator_aux4(__it, std::__addressof(*__other));
      | ^~~~~~~~
In file included from C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/exception_ptr.h:41,
 from C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/exception:164,
 from C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/optional:38,
 from C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/llvm/include/llvm/ADT/None.h:20,
 from C:/Users/waj33/Projects/sigo/thirdparty/llvm-project/mlir/include/mlir/Support/LLVM.h:23:
C:/mingw-64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/move.h:49:22: note:   initializing argument 1 of 'constexpr _Tp* std::__addressof(_Tp&) [with _Tp = long long int]'
   49 |     __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
      |                 ~~~~~^~~
[552/5315] Building CXX object tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/OpDefinitionsGen.cpp.obj
ninja: build stopped: subcommand failed.
```


```
PS C:\Users\waj33> g++ -v
Using built-in specs.
COLLECT_GCC=C:\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-11.2.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/x86_64-1120-posix-seh-rt_v9-rev1/mingw64 --enable-host-shared --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static --with-mpc=/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static --with-isl=/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev1, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/x86_64-1120-posix-seh-rt_v9-rev1/mingw64/opt/include -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-zlib-static/include -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/x86_64-1120-posix-seh-rt_v9-rev1/mingw64/opt/include -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-zlib-static/include -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/x86_64-1120-posix-seh-rt_v9-rev1/mingw64/opt/include -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-zlib-static/include -I/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/x86_64-1120-posix-seh-rt_v9-rev1/mingw64/opt/lib -L/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-zlib-static/lib -L/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/prerequisites/x86_64-w64-mingw32-static/lib ' LD_FOR_TARGET=/d/a/mingw-builds-binaries/mingw-builds-binaries/buildroot/x86_64-1120-posix-seh-rt_v9-rev1/mingw64/bin/ld.exe --with-boot-ldflags=' -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (x86_64-posix-seh-rev1, Built by MinGW-W64 project)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW1tz2yj7_zTkhsFjIx8vcuFIdl7P3zlM7G56p8ESkuki0AJynL34f_Z3ANmSU7d9e0iyM9tM60TAc_7x8IAw0ZrlgtJLMLgCg-iCVGYr1eUT-RQE_YuNTJ8vH7dUwEQWJeNM5FAK-MhEKp80rLRtKJjIn4Z9gEO4gDk10GwpzCTn8sl2U6WkAsEUdCPQnYJht_7nHufTxXIWgWAKjZRcAzwvOFMAz9uPyGx4TgXA8_CG_EnnjNMXXZ3UES2Xf9wsHkIpdlRpJsU1FZ2kLDty88mLC60eg9BpjIZ9MAg3TIBBmAB8BfBVh-4pRNHs4_3sdrX4YxaH_5mF_7eCKLpez1br-D_TVfywXi9AEHUhim6Wi4c4_BBN4_Du9o_Zw2pxd7uKZ7fTK2dTM-bhLrz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