[Bug c++/29252] New: Strange "No matching function for call" compilation error with G++ 4.1

2006-09-27 Thread yuanfei8077 at gmail dot com
Hi there,

I am porting some code to SUSE 10, with G++ 4.1. And hit an strange
"no matching function call" compilation error.  I am confused because
the calling function and candidate are nearly 100% same.

I wonder if this is a known G++ limitation or issue ? Because the same
program got compiled with VC8.

Below is the compilation environment info and compilation error.

 env info
=
g++ (GCC) 4.1.0  (SUSE Linux 10), note that this issue can also be found at G++
3.2(UL1.0)

No compile option is added


Compilation error
==
 ./Cache/CacheManager.h:424: error: no matching function for call to
tdat_hash_map,
std::allocator >, Element,
std::allocator > >*,
MemAllocator, std::allocator >, Element, std::allocator > >*> >
>::tdat_hash_map1(MemAllocator, std::allocator >, Element, std::allocator > >*> >, int)

./Common/TdatHashMap.h:250: note: candidates are: static void
tdat_hash_map<_Key, _Tp, _AllocType>::tdat_hash_map1(_AllocType&, int)
[with _Key = std::basic_string,
std::allocator >, _Tp = Element,
std::allocator > >*, _AllocType =
MemAllocator, std::allocator >, Element, std::allocator > >*> >]



Any comments/suggestions are higly appreciated.

Thanks,
-Kelvin


-- 
   Summary: Strange "No matching function for call" compilation
error with G++ 4.1
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: critical
  Priority: P3
     Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yuanfei8077 at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29252



[Bug c++/29252] Strange "No matching function for call" compilation error with G++ 4.1

2006-09-27 Thread yuanfei8077 at gmail dot com


--- Comment #2 from yuanfei8077 at gmail dot com  2006-09-28 01:50 ---
Hi,

For your convinence, the following is the reproduction code.

Many Thanks,
-Kelvin


Compilation error
=
no matching function for call to tdat_hash_map
>::func(MemAllocator)

main.cpp:6: note: candidates are: static void
tdat_hash_map<_AllocType>::func(_AllocType&) 
[with _AllocType = MemAllocator]


Repro code
===
template  class MemAllocator{};

template  class tdat_hash_map {
public:
typedef _AllocType _Alloc;
static void func(_Alloc&) {};
};

int main()
{
typedef tdat_hash_map > Map;
Map::func((MemAllocator) (MemAllocator()));

    return 0;
}


-- 

yuanfei8077 at gmail dot com changed:

   What|Removed |Added

 Status|WAITING |UNCONFIRMED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29252



[Bug c++/29261] New: Hiding constructior is required while no direct invocation to it with G++ 4

2006-09-27 Thread yuanfei8077 at gmail dot com
Hi there,



I found that the compiling the following code will fail with g++ 4.1
while cmopile succeed with VC8.  I suspect this is a g++ error.

 env info
=
g++ (GCC) 4.1.0  (SLES10)

No compile option is added


Compilation error

=
main.cpp: In copy constructor MemAllocator::MemAllocator(const
MemAllocator&)
main.cpp:5: error: MemPool::MemPool(const MemPool&) is protected
main.cpp:8: error: within this context
main.cpp: In function int main()
main.cpp:32: note: synthesized method
MemAllocator::MemAllocator(const MemAllocator&) first
required here



Repro code
===
class MemPool {
public:
   MemPool(){};
protected:
   MemPool(const MemPool& mempool);
};

template  class MemAllocator{
public:
   MemPool m_pool;
   MemAllocator(){}
   MemPool& get_pool() const {
   return m_pool;
   }
   template
   MemAllocator& operator=(const MemAllocator& rhs){
   m_pool = rhs.get_pool;
   return *this;
   }
};


template  class tdat_hash_map {
public:
   typedef _AllocType _Alloc;
   static void func(_Alloc&) {};
};

int main()
{
   typedef tdat_hash_map > Map;
   MemAllocator abc = MemAllocator();

   return 0;
}




Thanks,
-Kelvin


-- 
   Summary: Hiding constructior is required while no direct
invocation to it with G++ 4
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: yuanfei8077 at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29261



[Bug c++/29266] New: Rule that binding rvalue to a refernce need a copy ctor don't work

2006-09-28 Thread yuanfei8077 at gmail dot com
Hi,

I used to open a issue at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29261 and
it's closed as no a bug.  Also it says that to bind an rvalue to a reference,
we need to let copy ctor of the class be accessible.  However, I found that
this is not the case when the invokcation is happen in intialization list.

See below reproduction code and error message.
Env:
=
G++ 4.1
No compile option is used

Source code:
==

using std::cout;
using std::endl;


class MemPool {
public:
   MemPool(){};
protected:
   MemPool(const MemPool& mempool);

};

template  class MemAllocator{

public:
   MemAllocator(MemPool& pool):m_pool(pool){}
   MemPool& get_pool() const {
   return m_pool;
   }
   template
   MemAllocator& operator=(const MemAllocator& rhs){
   m_pool = rhs.get_pool();
   return *this;
   }
   MemAllocator& operator=(const MemAllocator& rhs){
   m_pool = rhs.get_pool();
   return *this;
   }

   MemAllocator(const MemAllocator& other)
   : m_pool(other.m_pool) {}
   template
   MemAllocator(const MemAllocator& other)
   : m_pool(other.get_pool()) {}

private:
   MemAllocator();
//  MemAllocator(const MemAllocator&);
   MemPool &m_pool;

};


template  class tdat_hash_map {
public:
   typedef _AllocType _Alloc;

   static void func(const _Alloc&) {};

   _Alloc malloc;
private:
   tdat_hash_map();
};
class CacheManager {
public:

   typedef tdat_hash_map > Map;

   Map caches;
   MemPool pool;
   CacheManager():caches(MemAllocator(pool)){};

};

Error message:
==
main.cpp: In constructor CacheManager::CacheManager()
main.cpp:56: error: no matching function for call to

tdat_hash_map

>::tdat_hash_map(MemAllocator)main.cpp:49: note: candidates are:
tdat_hash_map<_AllocType>::tdat_hash_map() [with _AllocType =
MemAllocator]
main.cpp:42: note: tdat_hash_map
>::tdat_hash_map(const tdat_hash_map >&)


-- 
   Summary: Rule that binding rvalue to a refernce need a copy ctor
don't work
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
    AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yuanfei8077 at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29266



[Bug c++/29266] Rule that binding rvalue to a refernce need a copy ctor don't work

2006-09-28 Thread yuanfei8077 at gmail dot com


--- Comment #2 from yuanfei8077 at gmail dot com  2006-09-28 23:25 ---
Subject: Re:  Rule that binding rvalue to a refernce need a copy ctor don't
work

Hi Andrew,

You are right, I am omitting the code, however, my question is:

1)
> t.cc:38: error: 'MemAllocator::MemAllocator() [with Type = int]' is
> private
> t.cc:49: error: within this context

However, MemAllocator is only invoked by class data member cache's
intialization list, and MemAllocator's copy constructor is already
provided, so you mean I am forced to offer default constructor too to
make it pass, right ?

2)
> There is no
> tdat_hash_map(_Alloc&) in the sources.

>::tdat_hash_map(MemAllocator)main.cpp:49: note: candidates are:
tdat_hash_map<_AllocType>::tdat_hash_map() [with _AllocType =
MemAllocator]
main.cpp:42: note: tdat_hash_map
>::tdat_hash_map(const tdat_hash_map >&)

But from the original error output, comiler have added a default
tdat_hash_map in line 42, and its format is same as what you added to
make "no matching" error disappear.  Can you explain explain why the
default can't work ?


Thanks for your help!

-Kelvin




On 28 Sep 2006 13:39:16 -, pinskia at gcc dot gnu dot org
<[EMAIL PROTECTED]> wrote:
>
>
> --- Comment #1 from pinskia at gcc dot gnu dot org  2006-09-28 13:39 
> ---
> There is no
> tdat_hash_map(_Alloc&) in the sources.
> Adding one makes it get past that error and then we get:
> t.cc: In constructor 'tdat_hash_map<_AllocType>::tdat_hash_map(const
> _AllocType&) [with _AllocType = MemAllocator]':
> t.cc:64:   instantiated from here
> t.cc:38: error: 'MemAllocator::MemAllocator() [with Type = int]' is
> private
> t.cc:49: error: within this context
>
>
> So this is invalid still.
>
>
> --
>
> pinskia at gcc dot gnu dot org changed:
>
>   What|Removed |Added
> 
> Status|UNCONFIRMED |RESOLVED
> Resolution||INVALID
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29266
>
> --- You are receiving this mail because: ---
> You reported the bug, or are watching the reporter.
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29266



[Bug c++/29266] Rule that binding rvalue to a refernce need a copy ctor don't work

2006-09-28 Thread yuanfei8077 at gmail dot com


--- Comment #3 from yuanfei8077 at gmail dot com  2006-09-29 03:02 ---
Plesae seee Comment #2 From Kelvin 2006-09-28 23:25 [reply].

In addition 2 questions I raised in the Commet2.  I also have one more question
about the rule "bind an rvalue to a reference,
we need to let copy ctor of the class be accessible.", I found that this rule
only effective when the reference is delcared as "const &", but if we remove
keyword "const", then "no matching" happen again. 




using std::cout;
using std::endl;


class MemPool {
public:
   MemPool(){};
protected:
   MemPool(const MemPool& mempool);

};

template  class MemAllocator{

public:
   MemAllocator(MemPool& pool):m_pool(pool){}
   MemPool& get_pool() const {
   return m_pool;
   }
   template
   MemAllocator& operator=(const MemAllocator& rhs){
   m_pool = rhs.get_pool();
   return *this;
   }
   MemAllocator& operator=(const MemAllocator& rhs){
   m_pool = rhs.get_pool();
   return *this;
   }

   MemAllocator(const MemAllocator& other)
   : m_pool(other.m_pool) {}
   template
   MemAllocator(const MemAllocator& other)
   : m_pool(other.get_pool()) {}

private:
   MemAllocator();
//  MemAllocator(const MemAllocator&);
   MemPool &m_pool;

};


template  class tdat_hash_map {
public:
   typedef _AllocType _Alloc;

   static void func(const _Alloc&) {};
   tdat_hash_map(const _Alloc&); // there will be error if const is removed

   _Alloc malloc;
private:
   tdat_hash_map();
};

class CacheManager {
public:

   typedef tdat_hash_map > Map;

   Map caches;
   MemPool pool;
   CacheManager():caches(MemAllocator(pool)){};

};


-- 

yuanfei8077 at gmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29266



[Bug c++/29266] Rule that binding rvalue to a refernce need a copy ctor don't work

2006-10-02 Thread yuanfei8077 at gmail dot com


--- Comment #6 from yuanfei8077 at gmail dot com  2006-10-02 14:19 ---
Subject: Re:  Rule that binding rvalue to a refernce need a copy ctor don't
work

Thank you Andrew, appreciate your help on this topic.

-Kelvin


On 1 Oct 2006 20:33:33 -, pinskia at gcc dot gnu dot org
<[EMAIL PROTECTED]> wrote:
>
>
> --- Comment #5 from pinskia at gcc dot gnu dot org  2006-10-01 20:33 
> ---
> (In reply to comment #3)
> > Plesae seee Comment #2 From Kelvin 2006-09-28 23:25 [reply].
> >
> > In addition 2 questions I raised in the Commet2.  I also have one more 
> > question
> > about the rule "bind an rvalue to a reference,
> > we need to let copy ctor of the class be accessible.", I found that this 
> > rule
> > only effective when the reference is delcared as "const &", but if we remove
> > keyword "const", then "no matching" happen again.
>
> Because it will not be a copy constructor that can bind a rvalue to a 
> reference
> at that point so this is still not a bug.
>
>
> --
>
> pinskia at gcc dot gnu dot org changed:
>
>   What|Removed |Added
> 
> Status|UNCONFIRMED |RESOLVED
> Resolution||INVALID
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29266
>
> --- You are receiving this mail because: ---
> You reported the bug, or are watching the reporter.
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29266