public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
@ 2002-12-03  7:56 Wolfgang Bangerth
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2002-12-03  7:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8778; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: Volker Reichelt <reichelt@igpm.rwth-aachen.de>, <gcc-gnats@gcc.gnu.org>,
   <gcc-bugs@gcc.gnu.org>, <sgunderson@bigfoot.com>
Subject: Re: c++/8778: ICE on illegal initialization of non-integral static
 in-class constant
Date: Tue, 3 Dec 2002 09:47:50 -0600 (CST)

 Gaby, Volker,
 
 let's settle this matter:
 
 
 > | > ------------------------snip here----------------------
 > | > template <int n> struct A
 > | > {
 > | >     static const int i[] = { 1, 2 };       // works
 > | > };
 > 
 > If this compiles with GCC then that is a compiler bug.  The program
 > construct is invalid.
 > 
 > [...]
 > 
 > | So maybe we can meet in the middle: "The code is illegal based on the C++ 
 > | standard, but is accepted as a gcc extension"?
 > 
 > I doubt that is an extension.
 
 I just filed report PR 8797 stating that the above syntax should not be
 accepted, or alternatively that the "extension" should be documented in
 the manual. I guess I lean towards the first alternative. Note also that
 using -pedantic yields a _warning_, not an error on the code above, so I
 guess having a separate report is justified.
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
@ 2002-12-03  7:26 Gabriel Dos Reis
  0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Dos Reis @ 2002-12-03  7:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8778; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: Volker Reichelt <reichelt@igpm.rwth-aachen.de>, gcc-gnats@gcc.gnu.org,
   <gcc-bugs@gcc.gnu.org>, <sgunderson@bigfoot.com>
Subject: Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
Date: 03 Dec 2002 16:18:44 +0100

 Wolfgang Bangerth <bangerth@ticam.utexas.edu> writes:
 
 | > You can really compile the following with gcc!!!
 | > 
 | > ------------------------snip here----------------------
 | > template <int n> struct A
 | > {
 | >     static const int i[] = { 1, 2 };       // works
 | > };
 
 If this compiles with GCC then that is a compiler bug.  The program
 construct is invalid.
 
 [...]
 
 | So maybe we can meet in the middle: "The code is illegal based on the C++ 
 | standard, but is accepted as a gcc extension"?
 
 I doubt that is an extension.
 
 -- Gaby


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
@ 2002-12-03  6:56 Wolfgang Bangerth
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2002-12-03  6:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8778; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
Cc: gcc-gnats@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <sgunderson@bigfoot.com>
Subject: Re: c++/8778: ICE on illegal initialization of non-integral static
 in-class constant
Date: Tue, 3 Dec 2002 08:53:54 -0600 (CST)

 Hi Volker,
 
 > I still don't agree with you ;-)
 
 Still not? I'm not arguing hard enough...
 
 > You can really compile the following with gcc!!!
 > 
 > ------------------------snip here----------------------
 > template <int n> struct A
 > {
 >     static const int i[] = { 1, 2 };       // works
 > };
 > 
 > ------------------------snip here----------------------
 
 I never doubted that you can compile it, but that does not make it legal.
 
 
 > Only with -pedantic you'll get a warning:
 > 
 > test.cc:3: warning: ISO C++ forbids initialization of member constant `i'
 > of non-integral type `const int[]'
 
 So maybe we can meet in the middle: "The code is illegal based on the C++ 
 standard, but is accepted as a gcc extension"?
 
 
 The point is moot anyway, since we certainly agree that an ICE is not an 
 appropriate behavior, the code being legal or not.
 
 Cheers :-)
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
@ 2002-12-02 16:36 Volker Reichelt
  0 siblings, 0 replies; 7+ messages in thread
From: Volker Reichelt @ 2002-12-02 16:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8778; it has been noted by GNATS.

From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: bangerth@ticam.utexas.edu
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, sgunderson@bigfoot.com
Subject: Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
Date: Tue, 3 Dec 2002 02:28:07 +0100

 Dear Wolfgang,
 
 I still don't agree with you ;-)
 
 On  2 Dec, Wolfgang Bangerth wrote:
 
 >> Initializing const arrays is usually supported by gcc.
 > 
 > True, but not as static member variables.
 
 You can really compile the following with gcc!!!
 
 ------------------------snip here----------------------
 template <int n> struct A
 {
     static const int i[] = { 1, 2 };       // works
 };
 
 ------------------------snip here----------------------
 
 Only with -pedantic you'll get a warning:
 
 test.cc:3: warning: ISO C++ forbids initialization of member constant `i'
 of non-integral type `const int[]'
 
 >> In fact, the code compiles if you just leave out the curly
 >> braces around the initializer.
 
 That refers to the original testcase. Just try it!
 
 Best regards,
 Volker
 
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
@ 2002-12-02 16:26 Wolfgang Bangerth
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2002-12-02 16:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8778; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
Cc: gcc-gnats@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <sgunderson@bigfoot.com>
Subject: Re: c++/8778: ICE on illegal initialization of non-integral static
 in-class constant
Date: Mon, 2 Dec 2002 18:19:36 -0600 (CST)

 > I don't quite agree with Wolfgangs analysis.
 
 :-)
 
 > Initializing const arrays is usually supported by gcc.
 
 True, but not as static member variables.
 
 > In fact, the code compiles if you just leave out the curly
 > braces around the initializer.
 > 
 > So the ICE is neither caused by the array initializer nor by the
 > infinite recursion (which might also come to mind as a compiler crasher)
 > as the following example shows:
 > 
 > --------------------snip here----------------------
 > template <int n> struct A
 > {
 >     static const int i = A<0>::i;     // works
 >     static const int i = { A<0>::i }; // ICE
 >     static const int i = { 1 };       // works
 > };
 > --------------------snip here----------------------
 
 Your analysis gives a clue as to what goes wrong in the compiler, but note 
 that the original code reads
        const static int result[] = { mylist<n-1>::result };
                              ^^^^
 This is what makes it illegal, not the curly braces. In your example, you 
 are initializing a scalar, he is initializing an array/pointer. However, 
 the curly braces seem to be the reason for the ICE, as you point out.
 
 But thanks for the analysis anyway, it will help those that actually fix 
 the problem :-)
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
@ 2002-12-02 16:06 Volker Reichelt
  0 siblings, 0 replies; 7+ messages in thread
From: Volker Reichelt @ 2002-12-02 16:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8778; it has been noted by GNATS.

From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org,
        sgunderson@bigfoot.com, bangerth@dealii.org
Cc:  
Subject: Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
Date: Tue, 3 Dec 2002 01:51:41 +0100

 I don't quite agree with Wolfgangs analysis.
 Initializing const arrays is usually supported by gcc.
 In fact, the code compiles if you just leave out the curly
 braces around the initializer.
 
 So the ICE is neither caused by the array initializer nor by the
 infinite recursion (which might also come to mind as a compiler crasher)
 as the following example shows:
 
 --------------------snip here----------------------
 template <int n> struct A
 {
     static const int i = A<0>::i;     // works
     static const int i = { A<0>::i }; // ICE
     static const int i = { 1 };       // works
 };
 --------------------snip here----------------------
 
 Regards,
 Volker
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8778
 
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: c++/8778: ICE on illegal initialization of non-integral static in-class constant
@ 2002-12-02 12:49 bangerth
  0 siblings, 0 replies; 7+ messages in thread
From: bangerth @ 2002-12-02 12:49 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, sgunderson

Old Synopsis: g++ 2.95/3.0.4/3.2/3.2.1 dies during template processing
New Synopsis: ICE on illegal initialization of non-integral static in-class constant

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Mon Dec  2 12:49:44 2002
State-Changed-Why:
    Confirmed.
    
    The code is illegal, though: you can only initialize
    _integral scalar constants_ inside the class. You try to
    do this with an array, which is not allowed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8778


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-12-03 15:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-03  7:56 c++/8778: ICE on illegal initialization of non-integral static in-class constant Wolfgang Bangerth
  -- strict thread matches above, loose matches on Subject: below --
2002-12-03  7:26 Gabriel Dos Reis
2002-12-03  6:56 Wolfgang Bangerth
2002-12-02 16:36 Volker Reichelt
2002-12-02 16:26 Wolfgang Bangerth
2002-12-02 16:06 Volker Reichelt
2002-12-02 12:49 bangerth

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).