First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 8766
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: andrew-message@ccl.bham.ac.uk
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 8766 depends on: Show dependency tree
Show dependency graph
Bug 8766 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2002-11-30 09:26
The general form of this bug seems (to my untrained eye) to be that when a
static member of a template class is declared correctly but initialised
incorrectly, GCC gets confused.

I've found two ways of triggering what appears to be the same bug -

        * A *

By causing an error with the line:
	static int n = 1;
gcc does the following:

test.cc:6: ISO C++ forbids in-class initialization of non-const static member `
   n'
test.cc: In instantiation of `foo<1>':
test.cc:17:   instantiated from here
test.cc:6: ISO C++ forbids in-class initialization of non-const static member `
   foo<1>::n'
g++-3.2: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
For Debian GNU/Linux specific bugs,
please see /usr/share/doc/debian/bug-reporting.txt.


        * B *

By causing an error with the line:
	static const int n = unsigned char(1);
gcc does the following:

$ g++-3.2 -Wall test.cc
test.cc:7: parse error before `char'
g++-3.2: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
For Debian GNU/Linux specific bugs,
please see /usr/share/doc/debian/bug-reporting.txt.

Release:
3.2.1 (Debian testing/unstable)

Environment:
System: Linux nautilus 2.4.19 #1 Fri Nov 1 18:58:16 GMT 2002 i686 unknown unknown GNU/Linux
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux

How-To-Repeat:
Contents of pre-processed file test.ii in case A:

# 1 "test.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.cc"
template <int i>
class foo {

        public:

        static int n = 1;


        char text[n];

        foo();

};

int main() {
        foo<1> e;
        return 0;
};


Contents of pre-processed file test.ii in case B:

# 1 "test.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.cc"
template <int i>
class foo {

        public:


        static const int n = unsigned char(1);


        char text[n];

        foo();

};

int main() {
        foo<1> e;
        return 0;
};

------- Comment #1 From andrew-message@ccl.bham.ac.uk 2002-11-30 09:26 -------
Fix:
Write correct code :)

------- Comment #2 From Wolfgang Bangerth 2002-12-02 12:30 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: I can confirm this. It is a regression of present 3.2 branch
    vs 3.2.0. Too bad :-(
    
    The symptom on my machine is that it enters a memory
    eating loop and only dies if it is killed or runs out
    of memory.

------- Comment #3 From Joe Buck 2003-01-24 17:40 -------
From: Joe Buck <jbuck@synopsys.com>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, andrew-message@ccl.bham.ac.uk,
   bangerth@ticam.utexas.edu
Cc:  
Subject: Re: c++/8766: [3.2->3.2.2 regression] cc1plus segfaults after failed
 initialisation of static template variable
Date: Fri, 24 Jan 2003 17:40:40 -0800

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8766
 
 Both test cases (A and B) work with gcc 3.2.0, fail with gcc 3.2.1 and 
 the current
 3_2_branch, and work in 3_3_branch and trunk.
 

------- Comment #4 From Joe Buck 2003-04-25 21:53 -------
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3.

First Last Prev Next    No search results available      Search page      Enter new bug