This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16174] New: [3.4/3.5 Regression] deducing top-level consts
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jun 2004 10:35:48 -0000
- Subject: [Bug c++/16174] New: [3.4/3.5 Regression] deducing top-level consts
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This comes from Rani Sharoni's implementation of auto_ptr:
http://tinyurl.com/2l2ge
--------------------------------------------------
template <class T> struct K
{
K();
K(K<T> & rhs);
K(K<T> const& rhs);
template <class U> K(K<U> const& rhs);
private:
template <class U> struct A;
template <class U> struct A< K<U> const>
{ typedef typename K<U>::compile_time_error type; };
// This is used to reject calls to the copy constructor
// with objects which are top-level const. If they are
// const, the specialization of A is instantiated and
// causes a compile time error. Otherwise, the general
// template is picked up, it misses definition, so this
// ctor declaration is rejected by SFINAE and everybody
// is happy.
// GCC 3.4.1pre and 3.5.0 always matches A's specialization
// when instantiating from foo(), and this causes the error.
template <class U>
K(U& rhs, typename A<U>::type = 0);
};
K<int> foo(void)
{
return K<int>();
}
--------------------------------------------------
This code works on any released GCC since 3.0, but stopped working on 3.4
branch and mainline lately, probably because of the work done by Nathan.
Nathan, can you check if the code is indeed invalid and we are now rightfully
rejecting it? Latest version of EDG accepts it.
--
Summary: [3.4/3.5 Regression] deducing top-level consts
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: giovannibajo at libero dot it
CC: gcc-bugs at gcc dot gnu dot org,nathan at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16174