pip010 / sparsehash

Automatically exported from code.google.com/p/sparsehash
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Problems compiling on VS2010 #59

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open solution in Visual C++ 2010
2. Try to compile

What is the expected output? What do you see instead?
I've expected some warnings, but not an error. 
1>  hashtable_test.cc
1>...\vc\include\utility(260): error C2166: l-value specifies const object

What version of the product are you using? On what operating system?
Visual Studio 2010 Ultimate / Windows Seven x64

Please provide any additional information below.

Original issue reported on code.google.com by wolfulus on 28 Sep 2010 at 6:58

GoogleCodeExporter commented 9 years ago
I don't have VC++ 2010, but in earlier versions of VC, the code compiles fine.

My guess is that there's something somewhere that is unhappy with my test of 
sparse_hash_map<const int, int>, but it's hard to be sure.  Can you please 
provide the *full* output of the make command?  If you can track down what it's 
complaining about, that would be great too.

Original comment by csilv...@gmail.com on 28 Sep 2010 at 7:17

GoogleCodeExporter commented 9 years ago
Sorry, paste failed :P! Here's the correct output:

1>ClCompile:
1>  port.cc
1>  hashtable_test.cc
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(260): 
error C2166: l-value specifies const object
1>          c:\program files (x86)\microsoft visual studio 
10.0\vc\include\utility(259) : while compiling class template member function 
'std::pair<_Ty1,_Ty2> &std::pair<_Ty1,_Ty2>::operator =(std::pair<_Ty1,_Ty2> 
&&)'
1>          with
1>          [
1>              _Ty1=const int,
1>              _Ty2=int
1>          ]
1>          d:\sources\sparsehash-1.9\src\hashtable_test.cc(327) : see 
reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
1>          with
1>          [
1>              _Ty1=const int,
1>              _Ty2=int
1>          ]
1>  Generating Code...
1>
1>Build FAILED.

Original comment by wolfulus on 28 Sep 2010 at 7:26

GoogleCodeExporter commented 9 years ago
Hmm:
} operator =(std::pair<_Ty1,_Ty2> &&)

This looks like c++0x to me.  Are you giving any special flags to the compile 
that's resulting in it compiling in c++0x mode?

http://code.google.com/p/google-sparsehash/source/browse/tags/sparsehash-1.9/src
/hashtable_test.cc whos line 327 is a close-brace, so I'm confused what's going 
on.  Are you trying to build sparsehash 1.9?

Original comment by csilv...@gmail.com on 28 Sep 2010 at 9:41

GoogleCodeExporter commented 9 years ago
Visual Studio 2010 already implements some things of C++0x, and, yes, I'm 
building version 1.9... the one on downloads section... I have no problems with 
the library itself (at least what I've tested for now), just this test case 
that isn't compiling right. You can try to compile it with Express versions, 
its free and small. I think it'll give the same result: 
http://www.microsoft.com/express/

Original comment by wolfulus on 29 Sep 2010 at 4:37

GoogleCodeExporter commented 9 years ago
Whew!  I finally was able to get VS 2010 installed -- it required upgrading my 
machine, which didn't have enough disk, and that involved upgrading to windows 
7, and... well, you don't need to know the rest.  But it was all done, and I 
was able to reproduce the problem and work around it.  (I still don't know 
what's causing it exactly, and the MSVC error messages were not helpful at all 
in figuring it out, but it seems to me to involve at least one MSVC bug, and 
possibly more.)

I've attached the workaround patch if you're curious.  This will be in the next 
release.

Original comment by csilv...@gmail.com on 9 Oct 2010 at 3:17

Attachments:

GoogleCodeExporter commented 9 years ago
> Whew!  I finally was able to get VS 2010 installed -- it required upgrading 
my machine, which didn't have enough disk, and that involved upgrading to 
windows 7, and...

))))))))))))
I've just finished the same job)))

Thanks for fixing, but there are more problems (as wolfulus I work on Win7 
VS2010Ultimate):

The hashtable_test project compiles after applying patch, but it encounters 
CRT-assertion while executing next after patched line of code

##################
//vector<typename TypeParam::value_type> input(4);
  vector<typename TypeParam::value_type> input;
    input.reserve(4);

  // We have to use placement-new because value_type may be const.
  new(&input[0]) typename TypeParam::value_type(this->UniqueObject(1));
// ^^^^^^ ASSERTION FAILED
##################

When new() executes, it triggers assert "vector subscript out of range" in

hashtable_test.exe!std::vector<std::pair<int const 
,int>,std::allocator<std::pair<int const ,int> > >::operator[](unsigned int 
_Pos)  Line 932 + 0x14 bytes    C++

here is snippet from there:

reference operator[](size_type _Pos)
        {   // subscript mutable sequence
 #if _ITERATOR_DEBUG_LEVEL == 2
        if (size() <= _Pos)
            {   // report error
            _DEBUG_ERROR("vector subscript out of range");
            _SCL_SECURE_OUT_OF_RANGE;
            }

size() equals 0 and _Post==0

I guess it is better so use input.resize(4), but it wont compile in such case 
with the same error 1>...\vc\include\utility(260): error C2166: l-value 
specifies const object

How can I help you to solve this problem?

Original comment by Al.Rech on 15 Nov 2010 at 10:48

GoogleCodeExporter commented 9 years ago
Ick.  I was so happy with my fix, too!  I'm thinking this test isn't that 
interesting -- it's mostly testing that sparse_hash_map uses stl::distance when 
it can, but I don't even verify that -- so replacing the vector with an array 
is probably fine.
   typename TypeParam::value_type> input[] = {
      this->Unique...(), ...
   }

Do you want to try that and see if it works for you?  If so, I'll just make 
that change for the next release.

Original comment by csilv...@gmail.com on 15 Nov 2010 at 10:52

GoogleCodeExporter commented 9 years ago
I've actually got a fix waiting to go, that I had forgotten about.  I'll see if 
I can get it into the svn repository tonight or tomorrow.

Original comment by csilv...@gmail.com on 16 Nov 2010 at 4:04

GoogleCodeExporter commented 9 years ago

Original comment by csilv...@gmail.com on 16 Nov 2010 at 4:17

GoogleCodeExporter commented 9 years ago
> Do you want to try that and see if it works for you?  If so, I'll just make 
that change for the next release.

Well, actually it required a bit more refactoring because of some vector API 
usage (I'll attach the file), but it compiles now and passes the test.

Thanks for your work, I really like sparsehash!

Original comment by Al.Rech on 16 Nov 2010 at 4:39

Attachments:

GoogleCodeExporter commented 9 years ago
It turns out I had to change the test for clang as well.  I've submitted a new 
version to the svn repository.  Do you want to try downloading the latest 
version of sparsehash from svn-root to see if it fixes the problem for you?  (I 
no longer have access to VC10.)

If it doesn't, I can look at how your fixes differ.  But it would be easier for 
me if you could apply your fixes as a patch, not as an entire file.  Hopefully 
this new version works for you, though!

Original comment by csilv...@gmail.com on 16 Nov 2010 at 11:25

GoogleCodeExporter commented 9 years ago
This should be fixed in sparsehash 1.10, just released.

Original comment by csilv...@gmail.com on 22 Jan 2011 at 3:48

GoogleCodeExporter commented 9 years ago
On your comment Nov 16, 2010 - I'm sorry, I didn't get a notification email 
about it and wasn't able to answer.

I've just finished to test v1.10 on vs2010/x64 and can confirm its OK now 
(strictly said, there was some minor warnings during compilation and I had to 
specify /bigobj compiler switch in order to compile x64/debug of 
hashtable_test, but that is not severe).

Thanks for the new release!

Original comment by Al.Rech on 22 Jan 2011 at 8:44