public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/26266] [4.0/4.1/4.2 regression] Trouble with static const data members in template classes
Date: Tue, 14 Feb 2006 17:13:00 -0000	[thread overview]
Message-ID: <20060214171305.1301.qmail@sourceware.org> (raw)
In-Reply-To: <bug-26266-6594@http.gcc.gnu.org/bugzilla/>



------- 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:

======================================
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?


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at codesourcery dot
                   |                            |com, reichelt at gcc dot gnu
                   |                            |dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |ice-on-valid-code,
                   |                            |monitored, rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2006-02-14 17:13:05
               date|                            |
            Summary|ICE                         |[4.0/4.1/4.2 regression]
                   |                            |Trouble with static const
                   |                            |data members in template
                   |                            |classes
   Target Milestone|---                         |4.0.3


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


  parent reply	other threads:[~2006-02-14 17:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-13 19:43 [Bug c++/26266] New: ICE igodard at pacbell dot net
2006-02-13 19:44 ` [Bug c++/26266] ICE igodard at pacbell dot net
2006-02-13 19:44 ` igodard at pacbell dot net
2006-02-13 20:25 ` pinskia at gcc dot gnu dot org
2006-02-13 20:29 ` pinskia at gcc dot gnu dot org
2006-02-14 17:13 ` reichelt at gcc dot gnu dot org [this message]
2006-02-14 19:26 ` [Bug c++/26266] [4.0/4.1/4.2 regression] Trouble with static const data members in template classes mark at codesourcery dot com
2006-02-14 20:38 ` reichelt at gcc dot gnu dot org
2006-02-14 20:40 ` igodard at pacbell dot net
2006-02-18  6:49 ` mmitchel at gcc dot gnu dot org
2006-02-18  8:36 ` mmitchel at gcc dot gnu dot org
2006-02-18  8:37 ` mmitchel at gcc dot gnu dot org
2006-02-18  8:37 ` mmitchel at gcc dot gnu dot org
2006-02-18  9:40 ` mmitchel at gcc dot gnu dot org
2006-02-18  9:41 ` mmitchel at gcc dot gnu dot org
2006-02-18  9:41 ` mmitchel at gcc dot gnu dot org
2006-02-24  0:31 ` mmitchel at gcc dot gnu dot org
2006-04-12  3:06 ` mmitchel at gcc dot gnu dot org
2006-05-25  2:37 ` mmitchel at gcc dot gnu dot org
2007-02-14  9:14 ` [Bug c++/26266] [4.0/4.1/4.2/4.3 " mmitchel at gcc dot gnu dot org
2007-12-16 23:18 ` steven at gcc dot gnu dot org
2007-12-18  5:34 ` mmitchel at gcc dot gnu dot org
2008-02-27 16:53 ` [Bug c++/26266] [4.0/4.1/4.2/4.3/4.4 " bangerth at dealii dot org
2008-07-04 20:21 ` [Bug c++/26266] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2009-02-21 22:17 ` steven at gcc dot gnu dot org
2009-02-21 22:27 ` mmitchel at gcc dot gnu dot org
2009-03-20 18:11 ` jason at gcc dot gnu dot org
2009-03-20 20:16 ` mark at codesourcery dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060214171305.1301.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).