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

Kim soldoutseashell at gmail.com
Sun Jun 23 21:15:09 PDT 2013


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);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\MinGW\include\c++\4.8.0\bits/alloc_traits.h:64:19: note: in 
instantiation of template class
       'std::__alloctr_rebind_helper<std::allocator<int>, int>' 
requested here
            bool = __alloctr_rebind_helper<_Alloc, _Tp>::__value>
                   ^
C:\MinGW\include\c++\4.8.0\bits/alloc_traits.h:202:9: note: in 
instantiation of default argument for 
'__alloctr_rebind<std::allocator<int>, int>'
       required here
         using rebind_alloc = typename __alloctr_rebind<_Alloc, 
_Tp>::__type;
         ^~~~~
C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:196:47: note: in 
instantiation of template type alias 'rebind_alloc' requested here
       { typedef typename _Base_type::template rebind_alloc<_Tp> other; };
                                               ^
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:74:59: note: in 
instantiation of template class 
'__gnu_cxx::__alloc_traits<std::allocator<int>
       >::rebind<int>' requested here
       typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
                                                           ^
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:210:30: note: in 
instantiation of template class 'std::_Vector_base<int, 
std::allocator<int> >' requested
       here
     class vector : protected _Vector_base<_Tp, _Alloc>
                              ^
simple.cpp:7:19: note: in instantiation of template class 
'std::vector<int, std::allocator<int> >' requested here
         std::vector<int> test;
                          ^
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:90:24: error: type 'int' 
cannot be used prior to '::' because it has no members
       typedef typename _Alloc::value_type value_type;
                        ^
C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:123:5: note: in 
instantiation of template class 'std::allocator_traits<int>' requested here
   : std::allocator_traits<_Alloc>
     ^
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:76:35: note: in 
instantiation of template class '__gnu_cxx::__alloc_traits<int>' 
requested here
       typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
                                   ^
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:210:30: note: in 
instantiation of template class 'std::_Vector_base<int, 
std::allocator<int> >' requested
       here
     class vector : protected _Vector_base<_Tp, _Alloc>
                              ^
simple.cpp:7:19: note: in instantiation of template class 
'std::vector<int, std::allocator<int> >' requested here
         std::vector<int> test;
                          ^
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:
C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:137:11: error: using 
declaration refers into '_Base_type::', which is not a base class of
       '__alloc_traits<int>'
     using _Base_type::allocate;
           ^~~~~~~~~~~~
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:76:35: note: in 
instantiation of template class '__gnu_cxx::__alloc_traits<int>' 
requested here
       typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
                                   ^
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:210:30: note: in 
instantiation of template class 'std::_Vector_base<int, 
std::allocator<int> >' requested
       here
     class vector : protected _Vector_base<_Tp, _Alloc>
                              ^
simple.cpp:7:19: note: in instantiation of template class 
'std::vector<int, std::allocator<int> >' requested here
         std::vector<int> test;
                          ^
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:
C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:138:11: error: using 
declaration refers into '_Base_type::', which is not a base class of
       '__alloc_traits<int>'
     using _Base_type::deallocate;
           ^~~~~~~~~~~~
C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:139:11: error: using 
declaration refers into '_Base_type::', which is not a base class of
       '__alloc_traits<int>'
     using _Base_type::construct;
           ^~~~~~~~~~~~
C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:140:11: error: using 
declaration refers into '_Base_type::', which is not a base class of
       '__alloc_traits<int>'
     using _Base_type::destroy;
           ^~~~~~~~~~~~
C:\MinGW\include\c++\4.8.0\ext/alloc_traits.h:141:11: error: using 
declaration refers into '_Base_type::', which is not a base class of
       '__alloc_traits<int>'
     using _Base_type::max_size;
           ^~~~~~~~~~~~
In file included from simple.cpp:2:
In file included from C:\MinGW\include\c++\4.8.0\vector:64:
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:80:16: error: base 
specifier must name a class
       : public _Tp_alloc_type
         ~~~~~~~^~~~~~~~~~~~~~
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:164:20: note: in 
instantiation of member class 'std::_Vector_base<int, std::allocator<int>
       >::_Vector_impl' requested here
       _Vector_impl _M_impl;
                    ^
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:210:30: note: in 
instantiation of template class 'std::_Vector_base<int, 
std::allocator<int> >' requested
       here
     class vector : protected _Vector_base<_Tp, _Alloc>
                              ^
simple.cpp:7:19: note: in instantiation of template class 
'std::vector<int, std::allocator<int> >' requested here
         std::vector<int> test;
                          ^
In file included from simple.cpp:2:
In file included from C:\MinGW\include\c++\4.8.0\vector:64:
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:237:13: error: using 
declaration refers into '_Base::', which is not a base class of
       'vector<int, std::allocator<int> >'
       using _Base::_M_allocate;
             ^~~~~~~
simple.cpp:7:19: note: in instantiation of template class 
'std::vector<int, std::allocator<int> >' requested here
         std::vector<int> test;
                          ^
In file included from simple.cpp:2:
In file included from C:\MinGW\include\c++\4.8.0\vector:64:
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:238:13: error: using 
declaration refers into '_Base::', which is not a base class of
       'vector<int, std::allocator<int> >'
       using _Base::_M_deallocate;
             ^~~~~~~
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:239:13: error: using 
declaration refers into '_Base::', which is not a base class of
       'vector<int, std::allocator<int> >'
       using _Base::_M_impl;
             ^~~~~~~
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:240:13: error: using 
declaration refers into '_Base::', which is not a base class of
       'vector<int, std::allocator<int> >'
       using _Base::_M_get_Tp_allocator;
             ^~~~~~~
C:\MinGW\include\c++\4.8.0\bits/stl_vector.h:529:13: error: using 
declaration refers into '_Base::', which is not a base class of
       'vector<int, std::allocator<int> >'
       using _Base::get_allocator;
             ^~~~~~~
13 errors generated.



More information about the cfe-dev mailing list