> cat bug.ii template<typename T> T declval(); template<typename T, typename... Args> struct is_constructible { template<typename T1, typename... Args1> static decltype(T1(declval<Args1>()...), char()) test(); static const bool value = sizeof(test<T, Args...>()) == 1; }; template<bool> struct enable_if { typedef void type; }; template<class T1, class T2> struct pair { template<class U2, class = typename enable_if<is_constructible<T2, U2&&>::value>::type> pair(const T1&, U2&&) { } }; struct string { string() : p(0) {} char* p; }; struct Foo { string s; int i; }; void f() { pair<int, Foo>(1, Foo()); } > g++ -g -O2 -std=c++0x bug.ii bug.ii: In instantiation of ‘const bool is_constructible<Foo, int&&>::value’: bug.ii:24:26: instantiated from here bug.ii:5:58: internal compiler error: in copy_fn_p, at cp/decl.c:9973 I'm using SVN revision trunk@155658 on linux x86_64.
Confirmed. Older releases ICE differently. Note that I don't see an ICE with -g0 but only with -g. With plain -g the code is even rejected: > ./cc1plus -quiet -std=c++0x t.ii ok > ./cc1plus -quiet -std=c++0x t.ii -g t.ii: In instantiation of 'const bool is_constructible<Foo, int&&>::value': t.ii:14:30: instantiated from here t.ii:5:61: error: no matching function for call to 'is_constructible<Foo, int&&>::test()' t.ii:14:30: error: 'is_constructible<Foo, int&&>::value' is not a valid template argument for type 'bool' because it is a non-constant expression t.ii: In constructor 'pair<T1, T2>::pair(const T1&, U2&&) [with U2 = Foo, <template-parameter-2-2> = void, T1 = int, T2 = Foo]': t.ii:14:30: error: 'is_constructible<Foo, int&&>::value' is not a valid template argument for type 'bool' because it is a non-constant expression
*** Bug 42639 has been marked as a duplicate of this bug. ***
Running into this as well.
I posted a candidate patch to http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00449.html
Created attachment 19547 [details] preprocessed source the attached testcase builds with the 4.4 branch, but not with 4.5. lowering optimization to -O1 works around the build failure. $ g++ -g -O2 -std=c++0x -c file_lie.ii In file included from /usr/include/c++/4.5/bits/move.h:38:0, from /usr/include/c++/4.5/bits/stl_pair.h:60, from /usr/include/c++/4.5/utility:71, from /usr/include/c++/4.5/unordered_map:42, from file_lie.cpp:22: /usr/include/c++/4.5/type_traits: In instantiation of 'const bool std::__is_constructible_helper<stat_override, override_key&&>::__value': /usr/include/c++/4.5/type_traits:235:5: instantiated from 'std::is_constructible<stat_override, override_key&&>' /usr/include/c++/4.5/bits/stl_pair.h:257:49: instantiated from here /usr/include/c++/4.5/type_traits:224:67: internal compiler error: in copy_fn_p, at cp/decl.c:9973 Please submit a full bug report, with preprocessed source if appropriate.
Subject: Bug 42634 Author: dodji Date: Wed Jan 13 20:06:26 2010 New Revision: 155868 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155868 Log: Fix PR c++/42634 gcc/cp/ChangeLog: PR c++/42634 * error.c (dump_template_parms): Use innermost template arguments before calling count_non_default_template_args. (count_non_default_template_args): We are being called with template innermost arguments now. There is no need to ensure that again. gcc/testsuite/ChangeLog: PR c++/42634 * g++.dg/template/error45.C: New test. Added: trunk/gcc/testsuite/g++.dg/template/error45.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/error.c trunk/gcc/testsuite/ChangeLog
Fixed in 4.5
Subject: Bug 42634 Author: dodji Date: Fri Jan 15 11:23:29 2010 New Revision: 155936 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155936 Log: Revert commit of PR c++/42634, which was commit r155868 Removed: trunk/gcc/testsuite/g++.dg/template/error45.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/error.c trunk/gcc/testsuite/ChangeLog
Re-opening, as the fix was reverted.
I'm running into this as well, but with code that clearly compiled fine with gcc 4.4. So maybe it's a slightly different issue.
It looks like the fix for PR42761 made the previous fix for this one (the one I reverted) acceptable now. I am waiting for Jason's comment at http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00964.html
Subject: Bug 42634 Author: dodji Date: Mon Jan 18 21:18:49 2010 New Revision: 156022 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156022 Log: Fix PR c++/42634 gcc/cp/ChangeLog: PR c++/42634 * error.c (dump_template_parms): Use innermost template arguments before calling count_non_default_template_args. (count_non_default_template_args): We are being called with template innermost arguments now. There is no need to ensure that again. gcc/testsuite/ChangeLog: PR c++/42634 * g++.dg/template/error45.C: New test. Added: trunk/gcc/testsuite/g++.dg/template/error45.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/error.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 42634 Author: dodji Date: Mon Jan 18 23:14:01 2010 New Revision: 156026 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156026 Log: Revert fix of PR c++/ gcc/cp/ChangeLog: * error.c (dump_template_parms, count_non_default_template_args): Revert fix of PR c++/42634. gcc/testsuite/ChangeLog: * g++.dg/template/error45.C: reverted as part of reverting the fix of PR c++/42634. Removed: trunk/gcc/testsuite/g++.dg/template/error45.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/error.c trunk/gcc/testsuite/ChangeLog
Created attachment 19656 [details] candidate fix I am testing this fix. I think one residual issue that was left to fix in the revert patch was that count_non_default_template_args is triggering some class type instantiation on the new std::bind related code, but it shouldn't. This patch tries to avoid that. But I'll sleep on it a bit. I have been bitten by it enough :-)
Subject: Bug 42634 Author: dodji Date: Fri Jan 29 14:30:41 2010 New Revision: 156351 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156351 Log: Fix PRs c++/42758, c++/42634, c++/42797 ... and mitigate PR c++/42336 gcc/cp/ChangeLog: PR c++/42758 PR c++/42634 PR c++/42336 PR c++/42797 PR c++/42880 * cp-tree.h (NON_DEFAULT_TEMPLATE_ARGS_COUNT, SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT, GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT): New accessor macros. * pt.c (coerce_template_parms, type_unification_real, expand_template_argument_pack, coerce_template_parameter_pack): Set the non default template args count. (current_template_args): Always set non defaulted template args count when compiled with --enable-checking (tsubst_template_args, type_unification_real): Propagate the non defaulted template args count. * error.c (get_non_default_template_args_count): Renamed count_non_default_template_args into this. Don't calculate the non default template argument count anymore. Use the new accessor macros above to get it. (dump_template_argument_list, dump_type, dump_decl, dump_template_parms): Adjust. * parser.c (cp_parser_template_argument_list): Always set defaulted template args count when compiled with --enable-checking. gcc/testsuite/ChangeLog: PR c++/42758 PR c++/42634 PR c++/42336 PR c++/42797 PR c++/42880 * g++.dg/other/crash-5.C: New test. * g++.dg/other/crash-6.C: New test. * g++.dg/other/crash-7.C: New test. * g++.dg/other/crash-8.C: New test. Added: trunk/gcc/testsuite/g++.dg/other/crash-5.C trunk/gcc/testsuite/g++.dg/other/crash-6.C trunk/gcc/testsuite/g++.dg/other/crash-7.C trunk/gcc/testsuite/g++.dg/other/crash-8.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/error.c trunk/gcc/cp/parser.c trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Hopefully fixed in 4.5 (trunk) now.
Subject: Bug 42634 Author: hjl Date: Sun Feb 7 04:41:22 2010 New Revision: 156562 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156562 Log: Backport testcases from mainline to 4.4. 2010-02-06 H.J. Lu <hongjiu.lu@intel.com> Backport from mainline: 2010-02-05 Dodji Seketeli <dodji@redhat.com> PR c++/42915 * g++.dg/other/crash-9.C: New test. 2010-02-03 Jason Merrill <jason@redhat.com> PR c++/40138 * g++.dg/ext/builtin11.C: New. 2010-02-03 Richard Guenther <rguenther@suse.de> PR tree-optimization/42944 * gcc.dg/errno-1.c: New testcase. 2010-02-03 Richard Guenther <rguenther@suse.de> PR middle-end/42927 * gcc.c-torture/compile/pr42927.c: New testcase. 2010-01-29 Dodji Seketeli <dodji@redhat.com> PR c++/42758 PR c++/42634 PR c++/42336 PR c++/42797 PR c++/42880 * g++.dg/other/crash-5.C: New test. * g++.dg/other/crash-7.C: New test. * g++.dg/other/crash-8.C: New test. 2010-01-28 Uros Bizjak <ubizjak@gmail.com> PR target/42891 * gcc.target/i386/pr42891.c: New test. 2010-01-28 Richard Guenther <rguenther@suse.de> PR middle-end/42883 * g++.dg/torture/pr42883.C: New testcase. 2010-01-28 Michael Matz <matz@suse.de> * gcc.target/i386/pr42881.c: New test. 2010-01-28 Dodji Seketeli <dodji@redhat.com> PR c++/42713 PR c++/42820 * g++.dg/template/typedef27.C: New test case. * g++.dg/template/typedef28.C: New test case. 2010-01-27 Jakub Jelinek <jakub@redhat.com> PR middle-end/42874 * gcc.dg/vla-22.c: New test. 2010-01-26 Richard Guenther <rguenther@suse.de> PR tree-optimization/42250 * gcc.dg/pr42250.c: New testcase. 2010-01-25 Tobias Burnus <burnus@net-b.de> PR fortran/42858 * gfortran.dg/generic_21.f90: New test. 2010-01-21 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42585 * gcc.dg/tree-ssa/pr42585.c: New test. 2010-01-20 Alexandre Oliva <aoliva@redhat.com> PR debug/42715 * gcc.dg/pr42715.c: New. 2010-01-20 Richard Guenther <rguenther@suse.de> PR tree-optimization/42717 * gcc.c-torture/compile/pr42717.c: New testcase. 2010-01-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/42783 * gfortran.dg/bounds_check_15.f90 : New test. 2010-01-18 Dodji Seketeli <dodji@redhat.com> PR c++/42766 * g++.dg/conversion/op6.C: New test. 2010-01-18 Richard Guenther <rguenther@suse.de> PR tree-optimization/42781 * gfortran.fortran-torture/compile/pr42781.f90: New testcase. 2010-01-17 Richard Guenther <rguenther@suse.de> PR middle-end/42248 * gcc.c-torture/execute/pr42248.c: New testcase. 2010-01-17 Janus Weil <janus@gcc.gnu.org> PR fortran/42677 * gfortran.dg/interface_assignment_5.f90: New test. 2010-01-15 Richard Guenther <rguenther@suse.de> PR middle-end/42739 * g++.dg/torture/pr42739.C: New testcase. 2010-01-14 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/42684 * gfortran.dg/interface_31.f90: New test. 2010-01-14 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42706 * gcc.dg/ipa/pr42706.c: New testcase. 2010-01-14 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42714 * g++.dg/torture/pr42714.C: New test. 2010-01-14 Alexander Monakov <amonakov@ispras.ru> PR rtl-optimization/42388 * gcc.dg/pr42388.c: New. 2010-01-14 Alexander Monakov <amonakov@ispras.ru> PR rtl-optimization/42294 * gfortran.dg/pr42294.f: New. 2010-01-14 Ira Rosen <irar@il.ibm.com> PR tree-optimization/42709 * gcc.dg/vect/pr42709.c: New test. 2010-01-13 Richard Guenther <rguenther@suse.de> PR tree-optimization/42730 * gcc.c-torture/compile/pr42730.c: New testcase. 2010-01-13 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42704 * g++.dg/torture/pr42704.C: New test. 2010-01-13 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42703 * gcc.c-torture/compile/pr42703.c: New test. 2010-01-13 Richard Guenther <rguenther@suse.de> PR tree-optimization/42705 * gcc.c-torture/compile/pr42705.c: New testcase. 2010-01-13 Richard Guenther <rguenther@suse.de> PR middle-end/42716 * gcc.c-torture/compile/pr42716.c: New testcase. 2010-01-12 Joseph Myers <joseph@codesourcery.com> PR c/42708 * gcc.c-torture/compile/pr42708-1.c: New test. 2010-01-09 Alexandre Oliva <aoliva@redhat.com> PR middle-end/42363 * gcc.dg/torture/pr42363.c: New. 2010-01-09 Alexandre Oliva <aoliva@redhat.com> PR debug/42604 PR debug/42395 * gcc.dg/vect/pr42604.c: New. * gcc.dg/vect/pr42395.c: New. 2010-01-09 Richard Guenther <rguenther@suse.de> PR middle-end/42512 * gcc.c-torture/execute/pr42512.c: New testcase. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/conversion/op6.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/conversion/op6.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/builtin11.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/ext/builtin11.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-5.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-5.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-7.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-7.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-8.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-8.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-9.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-9.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef27.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/template/typedef27.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef28.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/template/typedef28.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42704.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42704.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42714.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42714.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42739.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42739.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42883.C - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42883.C branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42703.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42703.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42705.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42705.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42708-1.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42708-1.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42716.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42716.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42717.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42717.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42730.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42730.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42927.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42927.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42248.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/execute/pr42248.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42512.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/execute/pr42512.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/errno-1.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/errno-1.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/ipa/pr42706.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/ipa/pr42706.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42250.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/pr42250.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42388.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/pr42388.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42715.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/pr42715.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr42363.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/torture/pr42363.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tree-ssa/pr42585.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/tree-ssa/pr42585.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr42395.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vect/pr42395.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr42604.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vect/pr42604.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr42709.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vect/pr42709.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vla-22.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vla-22.c branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr42881.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.target/i386/pr42881.c branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr42891.c - copied unchanged from r156561, trunk/gcc/testsuite/gcc.target/i386/pr42891.c branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/bounds_check_15.f90 - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/bounds_check_15.f90 branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/generic_21.f90 - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/generic_21.f90 branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/interface_31.f90 - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/interface_31.f90 branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/interface_assignment_5.f90 - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/interface_assignment_5.f90 branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/pr42294.f - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/pr42294.f branches/gcc-4_4-branch/gcc/testsuite/gfortran.fortran-torture/compile/pr42781.f90 - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.fortran-torture/compile/pr42781.f90 Modified: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog