Bug 23896 - [4.0/4.1 Regression] boost::tie() = std::pair doesn't compile
Summary: [4.0/4.1 Regression] boost::tie() = std::pair doesn't compile
Status: VERIFIED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.2
: P2 critical
Target Milestone: 4.0.2
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2005-09-15 14:52 UTC by André Wöbbeking
Modified: 2005-09-20 17:21 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.0.0
Known to fail: 4.0.2
Last reconfirmed: 2005-09-15 16:22:23


Attachments
example code, save-temps and compiler error message (14.81 KB, application/x-tbz2)
2005-09-15 14:54 UTC, André Wöbbeking
Details

Note You need to log in before you can comment on or make changes to this bug.
Description André Wöbbeking 2005-09-15 14:52:51 UTC
Hi,   
   
with Debian's gcc (version 4.0.2 20050913 (prerelease) (Debian 4.0.1-7)) this 
doesn't compile anymore: 
 
    const std::pair<int, int> p(1, 2); 
 
    int i, j; 
    boost::tie(i, j) = p; 
 
It works with all older versions and MSVC 7.1. 
 
 
Cheers, 
André
Comment 1 André Wöbbeking 2005-09-15 14:54:28 UTC
Created attachment 9735 [details]
example code, save-temps and compiler error message
Comment 2 Andrew Pinski 2005-09-15 15:14:17 UTC
Even after the fix for PR 23691, this still fails.  It worked with "4.0.2 20050826".
Comment 3 Andrew Pinski 2005-09-15 15:15:05 UTC
It also fails with "4.1.0 20050903".
Comment 4 Andrew Pinski 2005-09-15 15:21:44 UTC
Reducing.
Comment 5 Andrew Pinski 2005-09-15 16:22:23 UTC
Reduced as far as I could do:
namespace boost{
  template <bool x> struct STATIC_ASSERTION_FAILURE {};
  struct null_type;
  template <class T0 = null_type, class T1 = null_type, class T2 = null_type> class tuple;
  template <class TT> struct cons {
    typedef TT tail_type;
  };
  template<class T> struct length {
    static const int value = 1 + length<typename T::tail_type>::value;
  };
  template<> struct length<null_type> {
    static const int value = 0;
  };
  namespace detail {
    template <class T0, class T1, class T2> struct map_tuple_to_cons {
      typedef cons<typename map_tuple_to_cons<T1, T2, null_type>::type > type;
    };
    template <> struct map_tuple_to_cons<null_type, null_type, null_type> {
      typedef null_type type;
    };
  }
  template <class T0, class T1, class T2>  struct tuple : detail::map_tuple_to_cons<T0, T1, T2>::type     
{
    tuple& operator=(int t1) {
      int t = sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( length<tuple>::value == 2 ) >);
    }
  };
}
int main() {
  boost::tuple<int&, int&> a;
  a = 1;
}
Comment 6 Wolfgang Bangerth 2005-09-15 17:56:50 UTC
This is what I come up with: 
------------------- 
template <int> struct X {}; 
 
template <typename T> struct length { 
    static const int value = 2; 
}; 
 
template <typename T> void foo () { 
  sizeof(X<length<T>::value>); 
} 
 
template void foo<int>(); 
----------------------------- 
 
g/x> /home/bangerth/bin/gcc-3.4*-pre/bin/c++ -c x.cc 
 
g/x> /home/bangerth/bin/gcc-4.0*-pre/bin/c++ -c x.cc 
x.cc: In function &#8216;void foo() [with T = int]&#8217;: 
x.cc:11:   instantiated from here 
x.cc:8: error: &#8216;length<int>::value&#8217; is not a valid template argument for type 
&#8216;int&#8217; because it is a non-constant expression 
 
g/x> /home/bangerth/bin/gcc-4.1*-pre/bin/c++ -c x.cc 
x.cc: In function &#8216;void foo() [with T = int]&#8217;: 
x.cc:11:   instantiated from here 
x.cc:8: error: &#8216;length<int>::value&#8217; is not a valid template argument for type 
&#8216;int&#8217; because it is a non-constant expression 
 
W. 
Comment 7 Mark Mitchell 2005-09-15 18:05:33 UTC
Darn, I should never have fixed that original PR.  Silly me, trying to fix bugs.

Mine.
Comment 8 CVS Commits 2005-09-16 01:51:09 UTC
Subject: Bug 23896

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2005-09-16 01:50:26

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: static17.C 

Log message:
	PR c++/23896
	* pt.c (tsubst_aggr_type): Make sure skip_evaluation is false when
	processing template arguments.
	
	PR c++/23896
	* g++.dg/template/static17.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4893&r2=1.4894
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1036&r2=1.1037
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6068&r2=1.6069
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/static17.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 9 Mark Mitchell 2005-09-16 01:54:00 UTC
Fixed in 4.0.2.
Comment 10 CVS Commits 2005-09-16 01:54:14 UTC
Subject: Bug 23896

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	mmitchel@gcc.gnu.org	2005-09-16 01:53:43

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: static17.C 

Log message:
	PR c++/23896
	* pt.c (tsubst_aggr_type): Make sure skip_evaluation is false when
	processing template arguments.
	
	PR c++/23896
	* g++.dg/template/static17.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.104&r2=1.4648.2.105
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.25&r2=1.978.2.26
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.406&r2=1.5084.2.407
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/static17.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 11 André Wöbbeking 2005-09-17 08:30:26 UTC
Wow, that was fast, thanks. I'll give it a try with the next Debian package. 
Comment 12 André Wöbbeking 2005-09-20 17:21:24 UTC
Works for me. I hope VERIFIED is the same as CLOSED.