Skip to content

vector<bool> fails to compile its (iterator, iterator) constructor #12446

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

Closed
timurrrr opened this issue Feb 24, 2012 · 9 comments
Closed

vector<bool> fails to compile its (iterator, iterator) constructor #12446

timurrrr opened this issue Feb 24, 2012 · 9 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@timurrrr
Copy link
Contributor

Bugzilla Link 12074
Resolution FIXED
Resolved on Feb 27, 2014 18:27
Version trunk
OS Windows NT
Blocks llvm/llvm-bugzilla-archive#12477
CC @benlangmuir,@DougGregor,@tritao,@rnk

Extended Description

$ clang++.exe --version
clang version 3.1 (trunk 150962)
Target: i686-pc-win32
Thread model: posix

$ more vector_bool.cpp
#include
int main() {
std::vector foo(NULL, NULL);
}


$ clang++.exe vector_bool.cpp
[3 errors including]
In file included from vector_bool.cpp:1:
In file included from c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector:6:
In file included from c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\memory:6:
In file included from c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\iterator:6:
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility:995:3: error: template argument for template type parameter must be a type
iterator_traits<_Iter1>::iterator_category,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector:1044:19: note: in instantiation of function template specialization 'stdext::unchecked_copy<unsigned
int *, unsigned int *>' requested here
pointer _Ptr = _STDEXT unchecked_copy(_VEC_ITER_BASE(_Last), _Mylast,
^
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\yvals.h:490:27: note: expanded from macro '_STDEXT'
#define _STDEXT ::stdext::
^
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector:1097:3: note: in instantiation of member function 'std::vector<unsigned int, std::allocator >::erase' requested here
erase(begin(), end());
^
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector:871:3: note: in instantiation of member function 'std::vector<unsigned int, std::allocator >::_Assign_n' requested here
_Assign_n(_Count, _Val);
^
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector:1946:10: note: in instantiation of member function 'std::vector<unsigned int, std::allocator<unsigned

  int> >::assign' requested here
            _Myvec.assign(_Num, (_Ty)_Val ? -1 : 0);
                   ^

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector:1932:3: note: in instantiation of function template specialization 'std::vector<bool,
std::allocator >::_BConstruct' requested here
_BConstruct(_First, _Last, _Iter_cat(_First));
^
vector_bool.cpp:3:21: note: in instantiation of function template specialization 'std::vector<bool, std::allocator >::vector' requested here
std::vector foo(NULL, NULL);
^
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility:960:16: note: template parameter is declared here
template<class _Cat1, class _Cat2>
^


This prevents googletest from building under clang++

@DougGregor
Copy link
Contributor

This is clearly a bug in Microsoft's STL implementation, because

iterator_traits<_Iter1>::iterator_category

must be preceded by 'typename'.

That said, we could recover from this gracefully, and improve support for parsing Microsoft's broken STL implementation,

@timurrrr
Copy link
Contributor Author

Thanks Douglas, this makes sense.

As a temporary workaround, I've locally created a "fake" header for xutility and just add -IC:\llvm_fake_headers to my compile-time flags.
This works for me locally but indeed it'd be good to add support/workaround for this to Clang, at least in the MS compatibility mode.

Here's the diff:
C:\llvm_fake_headers>diff -u xutility "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility"
--- xutility Tue Feb 28 19:41:30 2012
+++ c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility Wed Aug 12 16:54:44 2009
@@ -992,8 +992,8 @@
__CLRCALL_OR_CDECL _Iter_random(const _Iter1&, const _Iter2&)
{ // return category from iterator argument
typename _Iter_random_helper<

  •           typename iterator_traits<_Iter1>::iterator_category,
    
  •           typename iterator_traits<_Iter2>::iterator_category>::_Iter_random_cat _Cat;
    
  •           iterator_traits<_Iter1>::iterator_category,
    
  •           iterator_traits<_Iter2>::iterator_category>::_Iter_random_cat _Cat;
      return (_Cat);
      }
    

@tritao
Copy link
Mannequin

tritao mannequin commented Jun 26, 2012

C:\LLVM\build\bin\Debug>clang -c -Xclang -cxx-abi -Xclang microsoft 12074.cpp -fsyntax-only
In file included from 12074.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\vector:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\memory:987:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\intrin.h:26:
C:/LVM/build/bin/Debug/../lib/clang/3.2/include\ammintrin.h:28:2: error: "SSE4A instruction set not enabled"
#error "SSE4A instruction set not enabled"
^
In file included from 12074.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\vector:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\memory:987:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\intrin.h:484:26: error: expected unqualified-id
__MACHINEX86X_IA64(__m64 _m_pshufw(__m64,int))

It seems there are some conflicts with MSVC intrinsincs.

@tritao
Copy link
Mannequin

tritao mannequin commented Jun 27, 2012

The MS compiler provides its own <intrin.h> that includes a lot of other intrinsic headers for different subsets of CPU functionality (MMX, SSE, etc...)

Some of them are provided by Clang build-in headers and they get picked up, but unfortunately, there are some problems with some defines being expected.

If those are relaxed, then the compiler errors later because some macros are defined and Clang provides the intrinsincs as functions instead of extern declarations.

I got a little farther with a custom <intrin.h> header based on the MinGW-w64 one, some of them need to be implemented in Clang itself, like the Interlocked* family of functions and some other stuff I did not yet research.

Need some feedback on how we want to proceed on this.

@tritao
Copy link
Mannequin

tritao mannequin commented Aug 27, 2012

This seems fixed in MSVC 2012, can't even find traces of the problematic code in xutility.

@benlangmuir
Copy link
Collaborator

C:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\INCLUDE\intrin.h:484:26: error: expected unqualified-id
__MACHINEX86X_IA64(__m64 _m_pshufw(__m64,int))

It seems there are some conflicts with MSVC intrinsincs.

I see the same errors using MSVS 2012 and including . Is there a PR for this intrin.h issue?

@tritao
Copy link
Mannequin

tritao mannequin commented Jun 28, 2013

Yes, there is llvm/llvm-bugzilla-archive#13283 .

@rnk
Copy link
Collaborator

rnk commented Feb 28, 2014

The program in question links and runs. We have our own intrin.h header now.

@timurrrr
Copy link
Contributor Author

mentioned in issue llvm/llvm-bugzilla-archive#12477

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

4 participants