menlong999 / sparsehash

Automatically exported from code.google.com/p/sparsehash
0 stars 0 forks source link

Compilation fails on SunOS CC compiler #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

The compiler is CC: Sun C++ 5.8 Patch 121018-11 2007/05/02

#include "google/dense_hash_map"
#include "google/sparse_hash_map"

// one that performs particularly well is the Jenkins One-at-a-time hash,
adapted here from an article by Bob Jenkins, its creator.
inline int joaat_hash( const char * key, int len )
{
    int hash = 0;
    for( int i = 0; i < len; ++i )
    {
        hash += (unsigned char) key[i];
        hash += (hash << 10);
        hash ^= (hash >> 6);
    }
    hash += (hash << 3);
    hash ^= (hash >> 11);
    hash += (hash << 15);
    return hash;
}

template<class T> struct my_hash
{
  size_t operator()( const std::string& x ) const
  {
    return joaat_hash( x.c_str(), x.length() );
  }
};

void test_func()
{
  typedef google::dense_hash_map<std::string, std::string,
my_hash<std::string> > gmap;
  gmap gm;
  gm.set_deleted_key( "" );
  gm.set_empty_key( " " );
  std::string s( "asdasdsadasd" );
  gm.erase( s );
  gm[s] = s;
  if( gm.end() != gm.find( s ) )
    gm[s] = s;

  typedef google::sparse_hash_map<std::string, std::string,
my_hash<std::string> > smap;
  smap sm;
  sm.set_deleted_key( "" );
  //sm.set_empty_key( " " );
  sm.erase( s );
  sm[s] = s;
  if( sm.end() != sm.find( s ) )
    sm[s] = s;
}

What is the expected output? What do you see instead?

These are the errors:

"src/main/Inc/google/sparsetable", line 656: Error: Too few arguments for
template
std::reverse_iterator<thirdparty::google::const_table_iterator<thirdparty::googl
e::sparsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>>>.
"src/main/Inc/google/sparsetable", line 1070:     Where: While specializing
"thirdparty::google::sparsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1070:     Where: Specialized in
non-template code.
"src/main/Inc/google/sparsetable", line 657: Error: Too few arguments for
template
std::reverse_iterator<thirdparty::google::table_iterator<thirdparty::google::spa
rsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>>>.
"src/main/Inc/google/sparsetable", line 1070:     Where: While specializing
"thirdparty::google::sparsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1070:     Where: Specialized in
non-template code.
"src/main/Inc/google/sparsetable", line 663: Error: Too few arguments for
template std::reverse_iterator<thirdparty::google::T*>.
"src/main/Inc/google/sparsetable", line 1070:     Where: While specializing
"thirdparty::google::sparsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1070:     Where: Specialized in
non-template code.
"src/main/Inc/google/sparsetable", line 664: Error: Too few arguments for
template std::reverse_iterator<const thirdparty::google::T*>.
"src/main/Inc/google/sparsetable", line 1070:     Where: While specializing
"thirdparty::google::sparsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1070:     Where: Specialized in
non-template code.
"src/main/Inc/google/sparsetable", line 1091: Error: Too few arguments for
template
std::reverse_iterator<thirdparty::google::const_table_iterator<thirdparty::googl
e::sparsetable<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>>>.
"src/main/Inc/google/sparsetable", line 1464:     Where: While specializing
"thirdparty::google::sparsetable<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1464:     Where: Specialized in
non-template code.
"src/main/Inc/google/sparsetable", line 1092: Error: Too few arguments for
template
std::reverse_iterator<thirdparty::google::table_iterator<thirdparty::google::spa
rsetable<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>>>.
"src/main/Inc/google/sparsetable", line 1464:     Where: While specializing
"thirdparty::google::sparsetable<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1464:     Where: Specialized in
non-template code.
"src/main/Inc/google/sparsetable", line 1100: Error: Too few arguments for
template
std::reverse_iterator<thirdparty::google::two_d_iterator<std::vector<thirdparty:
:google::sparsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE> >>>.
"src/main/Inc/google/sparsetable", line 1464:     Where: While specializing
"thirdparty::google::sparsetable<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1464:     Where: Specialized in
non-template code.
"src/main/Inc/google/sparsetable", line 1101: Error: Too few arguments for
template
std::reverse_iterator<thirdparty::google::const_two_d_iterator<std::vector<third
party::google::sparsegroup<thirdparty::google::T,
thirdparty::google::GROUP_SIZE> >>>.
"src/main/Inc/google/sparsetable", line 1464:     Where: While specializing
"thirdparty::google::sparsetable<thirdparty::google::T,
thirdparty::google::GROUP_SIZE>".
"src/main/Inc/google/sparsetable", line 1464:     Where: Specialized in
non-template code.
8 Error(s) detected.

What version of the product are you using? On what operating system?

Last version of the hash map

SunOS 5.10 Generic_118844-26 i86pc i386 i86pc

Please provide any additional information below.

May be a compatibility problem with STL of that specific compiler version.

Original issue reported on code.google.com by ascheti...@gmail.com on 15 Feb 2010 at 4:08

GoogleCodeExporter commented 9 years ago
It looks like the issue here is with the definition of reverse_iterator.  Can 
you 
find the definition of reverse_iterator in your standard headers for sunos c++ 
-- I'm 
sorry, I don't have a compiler to test on -- and list it here?  Here's the 
equivalent 
for gcc, in /usr/include/c++/4.2/bits/stl_iterator.h:
---
  template<typename _Iterator>
    class reverse_iterator [...]
---

It looks like reverse_iterator for sunos wants different arguments.

Original comment by csilv...@gmail.com on 18 Feb 2010 at 11:29

GoogleCodeExporter commented 9 years ago
Ah, I found some references to similar problems on the web:
  http://forums.sun.com/thread.jspa?threadID=5376208

What happens if you do
   ./configure CXXFLAGS=-library=stlport4 LDFALGS=-library=stlport4
?

I may be able to detect this automatically.

Original comment by csilv...@gmail.com on 18 Feb 2010 at 11:31

GoogleCodeExporter commented 9 years ago
I hit the same compilation error in trying to build 1.6 on Solaris 10 with a 
newer
version of the Sun compiler ("CC: Sun C++ 5.9 SunOS_i386 Patch 124864-05 
2008/06/03").

In order to build and run the tests I had to configure as suggested with
-library=stlport4 *and* then update src/google/sparsetable to std:: qualify
references to memset and memcpy, after which the tests build and run fine.

However I'd like to be able to build *without* -library=stlport (ie using the 
Sun
'native' Cstd standard library) as we have other external dependencies which 
require
this setup - but I'm not sure this is going to be possible given that (for 
example)
Boost only seems to build with stlport4...

Looking at the Cstd headers, they are full of #ifdef's so here is the
reverse_iterator declaration which is actually available after pre-processing:

template < class Iterator , class Category , class T , 
class Reference = T & , 
class Pointer = T * , 
class Distance = ptrdiff_t > 
class reverse_iterator 
: public iterator < Category , T , Distance , Pointer , Reference > 

Original comment by matt.stupple@gmail.com on 4 Mar 2010 at 8:49

GoogleCodeExporter commented 9 years ago
I'm happy to look at patches to get sparsehash working under sun cc.  I have no 
desire to be gcc-specific; I just don't have access to a sun compiler.

} configure as suggested with -library=stlport4 

What is the default stl library if you don't specify stlport?  Is there a 
reference 
page on it?  How hard would it be to convert sparsehash to using the new 
library?  
Perhaps it's just a question of defining the hash<> methods differently (like 
we 
already have to do for MSVC).  If so, it should be pretty straightforward.

} update src/google/sparsetable to std:: qualify references to memset and memcpy

OK, this I don't understand at all.  sparsetable #includes <string.h>, rather 
than 
<cstring>.  This should put all string routines in the standard namespace.  Do 
you 
know why it's not?

My guess is that something is #including <cstring> after <string.h>, and 
<cstring> 
not only defines stuff in std, it undefines stuff in the standard namespace.  
Can you 
maybe look into this a bit more?  Or alternately, remove the std:: 
qualifications and 
run 'make -k', and append the output here?

Original comment by csilv...@gmail.com on 4 Mar 2010 at 4:07

GoogleCodeExporter commented 9 years ago
Sorry for going quiet on this - I've got a stack of 'high priority' things on my
plate at the moment. Will try to revisit this issue when things calm down...

Original comment by matt.stupple@gmail.com on 3 Apr 2010 at 11:34

GoogleCodeExporter commented 9 years ago
I'm hoping to make a new release in the next day or two, so this may have to 
slip to the release after that, unless it turns out there's an easy fix for the 
problems you've been seeing.

Original comment by csilv...@gmail.com on 29 Jul 2010 at 5:31

GoogleCodeExporter commented 9 years ago
It's been over a year now, so I'm going to close this WillNotFix.  Feel free to 
reopen it (with patches!).

Original comment by csilv...@gmail.com on 26 Aug 2011 at 12:17