Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 24791
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: Michael Haubenwallner <michael.haubenwallner@salomon.at>
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 24791 depends on: Show dependency tree
Show dependency graph
Bug 24791 blocks: 28639 28641

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2006-08-30 03:40 Opened: 2005-11-11 09:43
tracked down sample is:

$ cat xx.cc

template < int I >
struct A
{
        int get_val() const;

        static int val_;
};

template< int I >
int A<I>::get_val() const
{
        return val_;
}

template< int I >    // this is invalid: works with "template <>"
int A<0>::val_(0);

// must instantiate to get ICE
template class A<0>;


$ g++ -v
Reading specs from
/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/specs
Configured with:
/tools/snapshot/src/sapc154/toolsbox-3.5.1.4pre.20051110/buildroot/gcc/gcc-3.4.4/configure
--with-gnu-as --with-gnu-ld --enable-threads=posix
--with-as=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/as
--with-ld=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/ld
--with-local-prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/ --disable-nls
--prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/
Thread model: posix
gcc version 3.4.4

$ g++ -v -c xx.cc
Reading specs from
/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/specs
Configured with:
/tools/snapshot/src/sapc154/toolsbox-3.5.1.4pre.20051110/buildroot/gcc/gcc-3.4.4/configure
--with-gnu-as --with-gnu-ld --enable-threads=posix
--with-as=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/as
--with-ld=/tools/snapshot/toolsbox-3.5.1.4pre.20051110//i686-pc-linux-gnu/bin/ld
--with-local-prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/ --disable-nls
--prefix=/tools/snapshot/toolsbox-3.5.1.4pre.20051110/
Thread model: posix
gcc version 3.4.4

/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.4/cc1plus
-quiet -v -iprefix
/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/
-D_GNU_SOURCE xx.cc -quiet -dumpbase xx.cc -mtune=pentiumpro -auxbase xx
-version -o /tmp/ccuQDWYE.s
ignoring nonexistent directory
"/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory
"/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4"
ignoring duplicate directory
"/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/i686-pc-linux-gnu"
ignoring duplicate directory
"/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/backward"
ignoring duplicate directory
"/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/include"
ignoring nonexistent directory
"/tools/snapshot/toolsbox-3.5.1.4pre.20051110//lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4

/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/i686-pc-linux-gnu

/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/backward

/tools/snapshot/toolsbox-3.5.1.4pre.20051110/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/include
 /tools/snapshot/toolsbox-3.5.1.4pre.20051110//include
 /usr/include
End of search list.
GNU C++ version 3.4.4 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.4.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
xx.cc:18: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

------- Comment #1 From Volker Reichelt 2005-11-17 10:39 -------
Confirmed.

The following code snippet causes an ICE since 2.95.3
with the exception of 4.0.0 - 4.0.2:

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

template<int> int A<0>::i(0);

A<0> a;
==================================

The following variation causes an ICE since 4.0.0 (and before 3.1)
and is accepted by GCC 3.1 - 3.4.5:

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

template<int> int A<0>::i(0);
==================================

------- Comment #2 From Volker Reichelt 2006-07-12 16:14 -------
*** Bug 28316 has been marked as a duplicate of this bug. ***

------- Comment #3 From Volker Reichelt 2006-08-15 19:07 -------
Btw, the ICE for the second testcase in comment #1 happens in
instantiate_decl, at cp/pt.c:11875

------- Comment #4 From Richard Guenther 2006-08-30 09:43 -------
*** Bug 28897 has been marked as a duplicate of this bug. ***

------- Comment #5 From Andrew Pinski 2006-12-16 20:28 -------
*** Bug 30234 has been marked as a duplicate of this bug. ***

------- Comment #6 From Volker Reichelt 2007-02-09 00:32 -------
Comment #3 is not quite correct:

The ICE for the first testcase in comment #1 is in
instantiate_decl, at cp/pt.c:12204

The ICE for the second testcase in comment #1 is in
import_export_decl, at cp/decl2.c:1956

------- Comment #7 From Volker Reichelt 2007-02-09 00:33 -------
*** Bug 30722 has been marked as a duplicate of this bug. ***

------- Comment #8 From Volker Reichelt 2007-02-09 00:34 -------
*** Bug 30721 has been marked as a duplicate of this bug. ***

------- Comment #9 From Andrew Pinski 2007-06-12 19:02 -------
*** Bug 32308 has been marked as a duplicate of this bug. ***

------- Comment #10 From Andrew Pinski 2007-08-11 11:27 -------
*** Bug 33046 has been marked as a duplicate of this bug. ***

------- Comment #11 From Andrew Pinski 2007-08-16 21:01 -------
*** Bug 33093 has been marked as a duplicate of this bug. ***

------- Comment #12 From Jason Merrill 2007-10-26 19:54 -------
Subject: Bug 24791

Author: jason
Date: Fri Oct 26 19:54:10 2007
New Revision: 129660

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129660
Log:
        PR c++/24791
        * pt.c (get_template_info): New fn.
        (template_class_depth): Use it.
        (push_template_decl_real): Check that the template args of the
        definition match the args of the previous declaration.

Added:
    trunk/gcc/testsuite/g++.dg/template/error33.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/g++.old-deja/g++.pt/crash11.C

------- Comment #13 From Volker Reichelt 2007-10-28 21:27 -------
Fixed by Jason's patch.

------- Comment #14 From Volker Reichelt 2007-10-28 21:31 -------
*** Bug 20133 has been marked as a duplicate of this bug. ***

------- Comment #15 From Andrew Pinski 2007-12-12 23:24 -------
*** Bug 34447 has been marked as a duplicate of this bug. ***

------- Comment #16 From Andrew Pinski 2008-01-17 02:19 -------
*** Bug 34822 has been marked as a duplicate of this bug. ***

------- Comment #17 From Andrew Pinski 2008-02-13 17:33 -------
*** Bug 35181 has been marked as a duplicate of this bug. ***

------- Comment #18 From Volker Reichelt 2008-12-30 01:18 -------
*** Bug 37970 has been marked as a duplicate of this bug. ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug