Bug 26266

Summary: [4.2/4.3/4.4 regression] Trouble with static const data members in template classes
Product: gcc Reporter: Ivan Godard <igodard>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: bangerth, fang, gcc-bugs, mark, pinskia, reichelt
Priority: P2 Keywords: accepts-invalid, monitored
Version: 4.0.2   
Target Milestone: 4.2.5   
Host: Target:
Build: Known to work: 3.4.5 4.0.1
Known to fail: 4.2.0 4.1.0 4.0.4 4.0.3 4.0.2 Last reconfirmed: 2006-08-28 05:28:17
Attachments: compiler output
source code (compressed)

Description Ivan Godard 2006-02-13 19:43:27 UTC
 
Comment 1 Ivan Godard 2006-02-13 19:44:00 UTC
Created attachment 10840 [details]
compiler output
Comment 2 Ivan Godard 2006-02-13 19:44:26 UTC
Created attachment 10841 [details]
source code (compressed)
Comment 3 Andrew Pinski 2006-02-13 20:25:52 UTC
I should say this is rejected in 4.1.0:
../include/row.hh: In member function ‘row<T>::operator const row<const T>() const [with T = unsigned int]’:
../include/powerset.hh:1027:   instantiated from ‘row<range<T> > powerset<E, alloc>::ranges(row<R>) [with R = unsigned int, E = unsigned int, alloc = standardAllocator]’
../include/powerset.hh:479:   instantiated from ‘powerset<E, alloc>::powerset(row<R>, const alloc<range<T> >&) [with R = unsigned int, E = unsigned int, alloc = standardAllocator]’
../include/display.hh:199:   instantiated from ‘basicDisplay<ch, tr>::basicDisplay(std::basic_ostream<_CharT, _Traits>&) [with ch = char, tr = std::char_traits<char>]’
../src/display.cc:8:   instantiated from here
../include/row.hh:210: error: conversion from ‘const range<const unsigned int*>’ to non-scalar type ‘const row<const unsigned int>’ requested
../include/powerset.hh: In member function ‘bool powerset<E, alloc>::insert(range<U>) [with R = wchar_t, E = wchar_t, alloc = standardAllocator]’:
../include/powerset.hh:863:   instantiated from ‘std::pair<typename powerset<E, alloc>::iterator, bool> powerset<E, alloc>::insert(const E&) [with E = wchar_t, alloc = standardAllocator]’
../include/powerset.hh:533:   instantiated from ‘powerset<E, alloc>& powerset<E, alloc>::operator<<(const E&) [with E = wchar_t, alloc = standardAllocator]’
../include/display.hh:200:   instantiated from ‘basicDisplay<ch, tr>::basicDisplay(std::basic_ostream<_CharT, _Traits>&) [with ch = wchar_t, tr = std::char_traits<wchar_t>]’
../src/display.cc:17:   instantiated from here
../include/powerset.hh:889: error: no matching function for call to ‘newRow(int, range<wchar_t>&)’
../include/row.hh: In member function ‘row<void>::operator row<T>() [with T = unsigned int]’:
../include/accum.hh:363:   instantiated from ‘row<R> accum<alloc>::frame<T>::space() [with T = unsigned int, alloc = standardAllocator]’
../include/accum.hh:250:   instantiated from ‘accum<alloc>::frame<T>::frame(accum<alloc>&) [with T = unsigned int, alloc = standardAllocator]’
../include/powerset.hh:1026:   instantiated from ‘row<range<T> > powerset<E, alloc>::ranges(row<R>) [with R = unsigned int, E = unsigned int, alloc = standardAllocator]’
../include/powerset.hh:479:   instantiated from ‘powerset<E, alloc>::powerset(row<R>, const alloc<range<T> >&) [with R = unsigned int, E = unsigned int, alloc = standardAllocator]’
../include/display.hh:199:   instantiated from ‘basicDisplay<ch, tr>::basicDisplay(std::basic_ostream<_CharT, _Traits>&) [with ch = char, tr = std::char_traits<char>]’
../src/display.cc:8:   instantiated from here
../include/row.hh:786: error: conversion from ‘const range<size_t*>’ to non-scalar type ‘row<unsigned int>’ requested
../include/row.hh: In member function ‘row<void>::operator row<T>() [with T = char]’:
../include/allocator.hh:484:   instantiated from ‘void allocatorMixin<void, D>::deallocate(row<void>) [with D = standardAllocator]’
../include/accum.hh:226:   instantiated from ‘void accum<alloc>::spare(row<void>) [with alloc = standardAllocator]’
../include/accum.hh:262:   instantiated from ‘accum<alloc>::frame<T>::~frame() [with T = range<unsigned int>, alloc = standardAllocator]’
../include/powerset.hh:1014:   instantiated from ‘row<range<T> > powerset<E, alloc>::ranges(row<R>) [with R = unsigned int, E = unsigned int, alloc = standardAllocator]’
../include/powerset.hh:479:   instantiated from ‘powerset<E, alloc>::powerset(row<R>, const alloc<range<T> >&) [with R = unsigned int, E = unsigned int, alloc = standardAllocator]’
../include/display.hh:199:   instantiated from ‘basicDisplay<ch, tr>::basicDisplay(std::basic_ostream<_CharT, _Traits>&) [with ch = char, tr = std::char_traits<char>]’
../src/display.cc:8:   instantiated from here
../include/row.hh:786: error: conversion from ‘const range<char*>’ to non-scalar type ‘row<char>’ requested
../include/row.hh: In member function ‘row<T>::operator const row<const T>() const [with T = wchar_t]’:
../include/display.hh:345:   instantiated from ‘void basicDisplay<ch, tr>::textBreak() [with ch = wchar_t, tr = std::char_traits<wchar_t>]’
../include/display.hh:157:   instantiated from ‘int basicDisplay<ch, tr>::sync() [with ch = wchar_t, tr = std::char_traits<wchar_t>]’
../include/display.hh:99:   instantiated from ‘basicDisplay<ch, tr>::~basicDisplay() [with ch = wchar_t, tr = std::char_traits<wchar_t>]’
../src/display.cc:20:   instantiated from here
../include/row.hh:210: error: conversion from ‘const range<const wchar_t*>’ to non-scalar type ‘const row<const wchar_t>’ requested
../include/row.hh: In member function ‘row<T>::operator const row<const T>() const [with T = char]’:
../include/display.hh:345:   instantiated from ‘void basicDisplay<ch, tr>::textBreak() [with ch = char, tr = std::char_traits<char>]’
../include/display.hh:157:   instantiated from ‘int basicDisplay<ch, tr>::sync() [with ch = char, tr = std::char_traits<char>]’
../include/display.hh:99:   instantiated from ‘basicDisplay<ch, tr>::~basicDisplay() [with ch = char, tr = std::char_traits<char>]’
../src/display.cc:20:   instantiated from here
../include/row.hh:210: error: conversion from ‘const range<const char*>’ to non-scalar type ‘const row<const char>’ requested
Comment 4 Andrew Pinski 2006-02-13 20:29:57 UTC
And I should say 4.1.0 is correct to reject this code.
Comment 5 Volker Reichelt 2006-02-14 17:13:05 UTC
Confirmed.

The ICE can be reduced to the following valid code snippet:

======================================
template<typename> struct A;

template<> struct A<char>
{
    static const char i = 1;
};

template<typename T> struct B
{
    static const int j = A<T>::i;
    static const int k = int(j);
    int x[k];
};

B<char> b;
======================================

bug.cc: In instantiation of 'const int B<char>::k':
bug.cc:12:   instantiated from 'B<char>'
bug.cc:15:   instantiated from here
bug.cc:11: internal compiler error: in build_c_cast, at cp/typeck.c:5231
Please submit a full bug report, [etc.]

This problem appeared with gcc 4.0.2, but does not show on the
current 4.0 branch. The ICE probably got only papered over, since
the following valid code is rejected now (it also caused an ICE
that appeared in GCC 4.0.2):

======================================
template<typename> struct A
{
    static const int i = 1;
};

template<typename> struct B
{
    static const int j = A<char>::i;
    static const int k = int(j);
    int x[k];
};

B<char> b;
======================================

bug.cc:13: error: variable-size type declared outside of any function
bug.cc:13: error: variable-size type declared outside of any function

This problem also exists on the 4.1 branch and mainline.

Last, but not least, the following valid code snippet is rejected
on the current 4.0 branch, as well as 4.1 branch and mainline:

======================================
template<typename> struct A
{
    static const int i = 1;
    static const int j = i;
    static const int k = int(j);
    int x[k];
};

A<char> a;
======================================

Mark, would you consider this a showstopper for the 4.1 release?
Comment 6 Mark Mitchell 2006-02-14 19:26:44 UTC
Subject: Re:  [4.0/4.1/4.2 regression] Trouble with static
 const data members in template classes

reichelt at gcc dot gnu dot org wrote:
> ------- Comment #5 from reichelt at gcc dot gnu dot org  2006-02-14 17:13 -------
> Confirmed.
> 
> The ICE can be reduced to the following valid code snippet:

Investigating.

Comment 7 Volker Reichelt 2006-02-14 20:38:39 UTC
One more datapoint:
The following invalid testcase is accepted since GCC 4.0.2:

===============================
template<int> struct A
{
    static const int i = A();
};

A<0> a;
===============================
Comment 8 Ivan Godard 2006-02-14 20:40:32 UTC
Gee, I turn over a rock and all sorts of creepy-crawlies come out :-)
Comment 9 Mark Mitchell 2006-02-18 06:49:16 UTC
I'm currently testing a patch for all of the critical problems in this PR; we'll be left with an accepts-invalid regression, which would only be P2.
Comment 10 Mark Mitchell 2006-02-18 08:36:16 UTC
Subject: Bug 26266

Author: mmitchel
Date: Sat Feb 18 08:36:11 2006
New Revision: 111229

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111229
Log:
	PR c++/26266
	* cp-tree.h (cp_finish_decl): Adjust declaration.
	(grokbitfield): Likewise.
	(finish_static_data_member_decl): Likewise.
	* init.c (constant_value_1): Ensure processing_template_decl when
	folding non-dependent initializers for static data members of
	dependent types.  Return error_mark_node for erroneous
	initailizers.
	* class.c (get_vtable_decl): Use finish_decl, not cp_finish_decl.
	* decl.c (cp_make_fname_decl): Adjust call to cp_finish_decl.
	(cp_finish_decl): Add init_const_expr_p parameter.  Set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(finish_decl): Adjust call to cp_finish_decl.
	(compute_array_index_type): Robustify.
	(start_method): Use finish_decl, not cp_finish_decl.
	* rtti.c (emit_tinfo_decl): Likewise.
	* except.c (initialize_handler_parm): Adjust call to
	cp_finish_decl.
	(expand_start_catch_block): Likewise.
	* cvt.c (build_up_reference): Adjust call to cp_finish_decl.
	* pt.c (instantiate_class_template): Adjust call to
	finish_static_data_member_decl.
	(tsubst_expr): Use finish_decl, not cp_finish_decl.
	(instantiate_decl): Adjust call to cp_finish_decl.
	* name-lookup.c (pushdecl_top_level_1): Use finish_decl, not
	cp_finish_decl.
	* decl2.c (finish_static_data_member_decl): Add init_const_expr_p
	parameter.
	(grokfield): Likewise.
	* parser.c (cp_parser_condition): Check for constant initializers.
	(cp_parser_init_declarator): Adjust calls to grokfield and
	cp_finish_decl.  Don't set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(cp_parser_member_declaration): Likewise.
	(cp_parser_objc_class_ivars): Likewise.
	PR c++/26266
	* g++.dg/template/static22.C: New test.
	* g++.dg/template/static23.C: New test.
	* g++.dg/template/static24.C: New test.
	* g++.dg/template/non-dependent13.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/non-dependent13.C
    trunk/gcc/testsuite/g++.dg/template/static22.C
    trunk/gcc/testsuite/g++.dg/template/static23.C
    trunk/gcc/testsuite/g++.dg/template/static24.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/cvt.c
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/except.c
    trunk/gcc/cp/init.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/rtti.c
    trunk/gcc/testsuite/ChangeLog

Comment 11 Mark Mitchell 2006-02-18 08:37:13 UTC
Subject: Bug 26266

Author: mmitchel
Date: Sat Feb 18 08:37:11 2006
New Revision: 111230

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111230
Log:
	PR c++/26266
	* g++.dg/template/static22.C: New test.
	* g++.dg/template/static23.C: New test.
	* g++.dg/template/static24.C: New test.
	* g++.dg/template/non-dependent13.C: New test.
	* g++.dg/init/member1.C: Tweak error markers.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/init/member1.C

Comment 12 Mark Mitchell 2006-02-18 08:37:38 UTC
Subject: Bug 26266

Author: mmitchel
Date: Sat Feb 18 08:37:34 2006
New Revision: 111231

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111231
Log:
	PR c++/26266
	* cp-tree.h (cp_finish_decl): Adjust declaration.
	(grokbitfield): Likewise.
	(finish_static_data_member_decl): Likewise.
	* init.c (constant_value_1): Ensure processing_template_decl when
	folding non-dependent initializers for static data members of
	dependent types.  Return error_mark_node for erroneous
	initailizers.
	* class.c (get_vtable_decl): Use finish_decl, not cp_finish_decl.
	* decl.c (cp_make_fname_decl): Adjust call to cp_finish_decl.
	(cp_finish_decl): Add init_const_expr_p parameter.  Set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(finish_decl): Adjust call to cp_finish_decl.
	(compute_array_index_type): Robustify.
	(start_method): Use finish_decl, not cp_finish_decl.
	* rtti.c (emit_tinfo_decl): Likewise.
	* except.c (initialize_handler_parm): Adjust call to
	cp_finish_decl.
	(expand_start_catch_block): Likewise.
	* cvt.c (build_up_reference): Adjust call to cp_finish_decl.
	* pt.c (instantiate_class_template): Adjust call to
	finish_static_data_member_decl.
	(tsubst_expr): Use finish_decl, not cp_finish_decl.
	(instantiate_decl): Adjust call to cp_finish_decl.
	* name-lookup.c (pushdecl_top_level_1): Use finish_decl, not
	cp_finish_decl.
	* decl2.c (finish_static_data_member_decl): Add init_const_expr_p
	parameter.
	(grokfield): Likewise.
	* parser.c (cp_parser_condition): Check for constant initializers.
	(cp_parser_init_declarator): Adjust calls to grokfield and
	cp_finish_decl.  Don't set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(cp_parser_member_declaration): Likewise.
	(cp_parser_objc_class_ivars): Likewise.
	PR c++/26266
	* g++.dg/template/static22.C: New test.
	* g++.dg/template/static23.C: New test.
	* g++.dg/template/static24.C: New test.
	* g++.dg/template/non-dependent13.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/non-dependent13.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/static22.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/static23.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/static24.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/class.c
    branches/gcc-4_1-branch/gcc/cp/cp-tree.h
    branches/gcc-4_1-branch/gcc/cp/cvt.c
    branches/gcc-4_1-branch/gcc/cp/decl.c
    branches/gcc-4_1-branch/gcc/cp/decl2.c
    branches/gcc-4_1-branch/gcc/cp/except.c
    branches/gcc-4_1-branch/gcc/cp/init.c
    branches/gcc-4_1-branch/gcc/cp/name-lookup.c
    branches/gcc-4_1-branch/gcc/cp/parser.c
    branches/gcc-4_1-branch/gcc/cp/pt.c
    branches/gcc-4_1-branch/gcc/cp/rtti.c
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/init/member1.C

Comment 13 Mark Mitchell 2006-02-18 09:40:08 UTC
Subject: Bug 26266

Author: mmitchel
Date: Sat Feb 18 09:40:03 2006
New Revision: 111233

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111233
Log:
	PR c++/26266
	* cp-tree.h (cp_finish_decl): Adjust declaration.
	(grokbitfield): Likewise.
	(finish_static_data_member_decl): Likewise.
	* init.c (constant_value_1): Ensure processing_template_decl when
	folding non-dependent initializers for static data members of
	dependent types.  Return error_mark_node for erroneous
	initailizers.
	* class.c (get_vtable_decl): Use finish_decl, not cp_finish_decl.
	* decl.c (cp_make_fname_decl): Adjust call to cp_finish_decl.
	(cp_finish_decl): Add init_const_expr_p parameter.  Set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(finish_decl): Adjust call to cp_finish_decl.
	(compute_array_index_type): Robustify.
	(start_method): Use finish_decl, not cp_finish_decl.
	* rtti.c (emit_tinfo_decl): Likewise.
	* except.c (initialize_handler_parm): Adjust call to
	cp_finish_decl.
	(expand_start_catch_block): Likewise.
	* cvt.c (build_up_reference): Adjust call to cp_finish_decl.
	* pt.c (instantiate_class_template): Adjust call to
	finish_static_data_member_decl.
	(tsubst_expr): Use finish_decl, not cp_finish_decl.
	(instantiate_decl): Adjust call to cp_finish_decl.
	* name-lookup.c (pushdecl_top_level_1): Use finish_decl, not
	cp_finish_decl.
	* decl2.c (finish_static_data_member_decl): Add init_const_expr_p
	parameter.
	(grokfield): Likewise.
	* parser.c (cp_parser_condition): Check for constant initializers.
	(cp_parser_init_declarator): Adjust calls to grokfield and
	cp_finish_decl.  Don't set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(cp_parser_member_declaration): Likewise.
	(cp_parser_objc_class_ivars): Likewise.

	PR c++/26266
	* g++.dg/template/static22.C: New test.
	* g++.dg/template/static23.C: New test.
	* g++.dg/template/static24.C: New test.
	* g++.dg/template/non-dependent13.C: New test.

Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 14 Mark Mitchell 2006-02-18 09:41:21 UTC
Subject: Bug 26266

Author: mmitchel
Date: Sat Feb 18 09:41:18 2006
New Revision: 111234

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111234
Log:
	PR c++/26266
	* cp-tree.h (cp_finish_decl): Adjust declaration.
	(grokbitfield): Likewise.
	(finish_static_data_member_decl): Likewise.
	* init.c (constant_value_1): Ensure processing_template_decl when
	folding non-dependent initializers for static data members of
	dependent types.  Return error_mark_node for erroneous
	initailizers.
	* class.c (get_vtable_decl): Use finish_decl, not cp_finish_decl.
	* decl.c (cp_make_fname_decl): Adjust call to cp_finish_decl.
	(cp_finish_decl): Add init_const_expr_p parameter.  Set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(finish_decl): Adjust call to cp_finish_decl.
	(compute_array_index_type): Robustify.
	(start_method): Use finish_decl, not cp_finish_decl.
	* rtti.c (emit_tinfo_decl): Likewise.
	* except.c (initialize_handler_parm): Adjust call to
	cp_finish_decl.
	(expand_start_catch_block): Likewise.
	* cvt.c (build_up_reference): Adjust call to cp_finish_decl.
	* pt.c (instantiate_class_template): Adjust call to
	finish_static_data_member_decl.
	(tsubst_expr): Use finish_decl, not cp_finish_decl.
	(instantiate_decl): Adjust call to cp_finish_decl.
	* name-lookup.c (pushdecl_top_level_1): Use finish_decl, not
	cp_finish_decl.
	* decl2.c (finish_static_data_member_decl): Add init_const_expr_p
	parameter.
	(grokfield): Likewise.
	* parser.c (cp_parser_condition): Check for constant initializers.
	(cp_parser_init_declarator): Adjust calls to grokfield and
	cp_finish_decl.  Don't set
	DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here.
	(cp_parser_member_declaration): Likewise.
	(cp_parser_objc_class_ivars): Likewise.
	PR c++/26266
	* g++.dg/template/static22.C: New test.
	* g++.dg/template/static23.C: New test.
	* g++.dg/template/static24.C: New test.
	* g++.dg/template/non-dependent13.C: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/non-dependent13.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/static22.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/static23.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/static24.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/class.c
    branches/gcc-4_0-branch/gcc/cp/cp-tree.h
    branches/gcc-4_0-branch/gcc/cp/cvt.c
    branches/gcc-4_0-branch/gcc/cp/decl.c
    branches/gcc-4_0-branch/gcc/cp/decl2.c
    branches/gcc-4_0-branch/gcc/cp/except.c
    branches/gcc-4_0-branch/gcc/cp/init.c
    branches/gcc-4_0-branch/gcc/cp/name-lookup.c
    branches/gcc-4_0-branch/gcc/cp/parser.c
    branches/gcc-4_0-branch/gcc/cp/pt.c
    branches/gcc-4_0-branch/gcc/cp/rtti.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/init/member1.C

Comment 15 Mark Mitchell 2006-02-18 09:41:57 UTC
Only the accepts-invalid in Comment #7 remains.
Comment 16 Mark Mitchell 2006-02-24 00:26:59 UTC
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Comment 17 Mark Mitchell 2006-04-12 03:06:24 UTC
The fix for the bug in Comment #7 is to implement DR224.  

The problem here is that we think that A is a dependent type; as such, it might be  int, and the initialization would be valid.  However, A is non-dependent according to DR224.  If we recognized that, we would correctly issue an error.

However, implementing DR224 is not trivial.  Making types that involve template parameters non-dependent is likely to trigger problems throughout the front end in routines that are using "dependent" as a synonym for "uses template parameters".
Comment 18 Mark Mitchell 2006-05-25 02:33:58 UTC
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
Comment 19 Steven Bosscher 2007-12-16 23:18:01 UTC
Open regression with no activity since February 14.  Ping?
Comment 20 Mark Mitchell 2007-12-18 05:34:17 UTC
I think Comment #17 still applies.  This is indeed an accepts-invalid regression, but it has no easy fix.
Comment 21 Wolfgang Bangerth 2008-02-27 16:52:59 UTC
Can someone check which of the testcases now work and separate
those that don't into PRs of their own? This PR has become
a bit confusing.

W.
Comment 22 Joseph S. Myers 2008-07-04 20:20:36 UTC
Closing 4.1 branch.  (It would still be useful for someone to split this bug up as suggested in the last comment.)
Comment 23 Steven Bosscher 2009-02-21 22:17:47 UTC
What is the "Assigned:" field worth if nothing happens for 3 years?

How about just moving this one to SUSPENDED?
Comment 24 Mark Mitchell 2009-02-21 22:26:57 UTC
The problem isn't the database schema; it's keeping it up to date.

I'm not actively working on this issue any more, so I've unassigned myself.
Comment 25 Jason Merrill 2009-03-20 18:11:15 UTC
I don't think the testcase in comment #7 indicates a bug at all.  We don't issue an error because we don't instantiate A<0>::i.  14.6 says:

If no valid specialization can be generated for a template definition, and that template is not instantiated, the template definition is ill-formed, no diagnostic required. If a type used in a non-dependent name is incomplete at the point at which a template is defined but is complete at the point at which an instantiation is done, and if the completeness of that type affects whether or not the program is well-formed or affects the semantics of the program, the program is ill-formed; no diagnostic is required.

So no diagnostic is required.  If we change the last line to

int i = A<0>::i;

we do instantiate A<0>::i, and we give the diagnostic.
Comment 26 Mark Mitchell 2009-03-20 20:16:28 UTC
Subject: Re:  [4.2/4.3/4.4 regression] Trouble with static
 const data members in template classes

jason at gcc dot gnu dot org wrote:

> I don't think the testcase in comment #7 indicates a bug at all.

FWIW, I concur with your analysis.

Thanks,