Clang issue MinGW STL alloc_traits.h error: in-class initializer for static data member is not a constant expression

I'm getting this error while trying to compile code including MinGW STL headers with clang, I'm wondering if perhaps mingw's headers aren't fully supported in the latest version or if (more likely) I'm missing some important arguments. I'm using clang built using visual studio 11 with disabled inbuilt directories. Should I downgrade to an earlier version/combination of mingw and clang that is confirmed to work well? I've also tried the visual studio headers but I was told many features won't work (yet).

Perhaps if someone is successfully compiling code on win with clang that uses the mingw headers they could share the complete set of arguments they are using. Would be much appreciated.

Thanks very much in advance.

Simple.cpp:

#include <vector>
#include <map>

int main()
{
      return 0;
}

Output

I'm getting this error while trying to compile code including MinGW STL
headers with clang, I'm wondering if perhaps mingw's headers aren't fully
supported in the latest version or if (more likely) I'm missing some
important arguments. I'm using clang built using visual studio 11 with
disabled inbuilt directories. Should I downgrade to an earlier
version/combination of mingw and clang that is confirmed to work well? I've
also tried the visual studio headers but I was told many features won't work
(yet).

Perhaps if someone is successfully compiling code on win with clang that
uses the mingw headers they could share the complete set of arguments they
are using. Would be much appreciated.

Thanks very much in advance.

Simple.cpp:

#include <vector>
#include <map>

int main()
{
     return 0;
}

Output

C:\Program Files (x86)\LLVM\vs11\bin\Debug>clang++ -fno-ms-compatibility
-nostdinc -std=c++11 -c -v -o simple.o simple.cpp -I "C:\MinGW\include\sys"
-I "C:\MinGW\lib\gcc\i686-pc-mingw32\4.8.0\include" -I "C:\MinGW\include" -I
"C:\MinGW\include\c++" -I "C:\MinGW\include\c++\4.8.0" -I
"C:\MinGW\include\c++\4.8.0\backward" -I "C:\MinGW\include\c++\4.8.0\bits"
-I "C:\MinGW\include\c++\4.8.0\debug" -I
"C:\MinGW\include\c++\4.8.0\decimal" -I "C:\MinGW\include\c++\4.8.0\ext" -I
"C:\MinGW\include\c++\4.8.0\i686-pc-mingw32" -I
"C:\MinGW\include\c++\4.8.0\tr1" -I "C:\MinGW\include\c++\4.8.0\tr2" -I
"C:\MinGW\include\c++\4.8.0\profile"
clang version 3.4 (trunk)
Target: i686-pc-win32
Thread model: posix
"C:/Program Files (x86)/LLVM/vs11/bin/Debug/clang++.exe" -cc1 -triple
i686-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-name simple.cpp
-mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -target-cpu pentium4 -v -coverage-file simple.o
-nostdsysteminc -nobuiltininc -resource-dir "C:/Program Files
(x86)/LLVM/vs11/bin/Debug\\..\\lib\\clang\\3.4" -I "C:\\MinGW\\include\\sys"
-I "C:\\MinGW\\lib\\gcc\\i686-pc-mingw32\\4.8.0\\include" -I
"C:\\MinGW\\include" -I "C:\\MinGW\\include\\c++" -I
"C:\\MinGW\\include\\c++\\4.8.0" -I
"C:\\MinGW\\include\\c++\\4.8.0\\backward" -I
"C:\\MinGW\\include\\c++\\4.8.0\\bits" -I
"C:\\MinGW\\include\\c++\\4.8.0\\debug" -I
"C:\\MinGW\\include\\c++\\4.8.0\\decimal" -I
"C:\\MinGW\\include\\c++\\4.8.0\\ext" -I
"C:\\MinGW\\include\\c++\\4.8.0\\i686-pc-mingw32" -I
"C:\\MinGW\\include\\c++\\4.8.0\\tr1" -I
"C:\\MinGW\\include\\c++\\4.8.0\\tr2" -I
"C:\\MinGW\\include\\c++\\4.8.0\\profile" -std=c++11 -fdeprecated-macro
-ferror-limit 19 -fmessage-length 150 -mstackrealign -fms-extensions
-fmsc-version=1300 -fdelayed-template-parsing -fobjc-runtime=gcc
-fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -backend-option
-vectorize-loops -o simple.o -x c++ simple.cpp
clang -cc1 version 3.4 based upon LLVM 3.4svn default target i686-pc-win32
#include "..." search starts here:
#include <...> search starts here:
C:\MinGW\include\sys
C:\MinGW\lib\gcc\i686-pc-mingw32\4.8.0\include
C:\MinGW\include
C:\MinGW\include\c++
C:\MinGW\include\c++\4.8.0
C:\MinGW\include\c++\4.8.0\backward
C:\MinGW\include\c++\4.8.0\bits
C:\MinGW\include\c++\4.8.0\debug
C:\MinGW\include\c++\4.8.0\decimal
C:\MinGW\include\c++\4.8.0\ext
C:\MinGW\include\c++\4.8.0\i686-pc-mingw32
C:\MinGW\include\c++\4.8.0\tr1
C:\MinGW\include\c++\4.8.0\tr2
C:\MinGW\include\c++\4.8.0\profile
End of search list.
In file included from simple.cpp:2:
In file included from C:\MinGW\include\c++\4.8.0\vector:62:
In file included from C:\MinGW\include\c++\4.8.0\bits/stl_construct.h:61:
In file included from C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:36:
C:\MinGW\include\c++\4.8.0\bits/alloc_traits.h:57:31: error: in-class
initializer for static data member is not a constant expression
                static const bool __value = _S_chk<_Alloc, _Tp>(nullptr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~

What is _S_chk?

What is _S_chk?

_S_chk is a member function from a class in alloc_traits.h

  template<typename _Alloc, typename _Tp>
    class __alloctr_rebind_helper
    {
      template<typename _Alloc2, typename _Tp2>
    static constexpr bool
           _S_chk(typename _Alloc2::template rebind<_Tp2>::other*)
    { return true; }

      template<typename, typename>
        static constexpr bool
           _S_chk(...)
           { return false; }

    public:

    static const bool __value = _S_chk<_Alloc, _Tp>(nullptr);
    };

OK, this is llvm.org/PR15651. Essentially, -fdelayed-template-parsing
(which is enabled by default on some Windows targets) is currently
incompatible with constexpr. -fno-delayed-template-parsing will
probably help (if it doesn't cause breakage in other headers). I
wonder if we should stop enabling -fno-delayed-template-parsing by
default on MinGW -- MinGW's gcc presumably doesn't behave that way.

We don't enable -fdelayed-template-parsing when targetting mingw. The
original invocation didn't specify an OS, so the triple defaulted to
...-win32.

You should use 'clang --target=i686-pc-mingw32' to get regular template
parsing and to match the small struct passing ABI, as well as other things
I can't recall.