Bug 9779 - [3.4 regression] ICE in type_unknown_p when casting in static member
Summary: [3.4 regression] ICE in type_unknown_p when casting in static member
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 3.4.0
Assignee: Nathan Sidwell
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2003-02-20 18:06 UTC by Benjamin Kosnik
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-01 15:44:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Kosnik 2003-02-20 18:06:00 UTC
This bug is apparently holding up a a new allocator implementation, so any assistance appreciated.This is a regression on mainline from 3.2.x series compilers.

See:

http://gcc.gnu.org/ml/libstdc++/2003-02/msg00309.html

Release:
gcc version 3.4 20030217 (experimental), NOT 3.2.x

Environment:
x86/linux

How-To-Repeat:
typedef unsigned int size_t;
extern "C" void *malloc(size_t size);

namespace std
{
  template<bool __threads, int __inst>
    class __pool_alloc
    {
    public:
      void
      _S_chunk_alloc(size_t __size, int& __nobjs);
    };

  template<bool __threads, int __inst>
    void
    __pool_alloc<__threads, __inst>::
    _S_chunk_alloc(size_t __size, int& __nobjs)
#if 1
    // ICE
  { void* foo = malloc(sizeof(int)); }
#else
  // Works
  {
    size_t s = sizeof(int);
    void* foo = malloc(s);
  }
#endif
}

namespace std
{
  template class __pool_alloc<true, 0>;
}
Comment 1 Wolfgang Bangerth 2003-02-20 20:15:38 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Here's a smaller snippit:
    -------------------
    void *malloc(unsigned int size);
    
    template<int> void foo() {
      malloc (sizeof (int));
    }
    
    template void foo<1>();
    --------------------------
    g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
    x.cc: In function `void foo()':
    x.cc:5: internal compiler error: Segmentation fault
    
    
    This ICEs present mainline, and the regression was
    introduced between 2002-12-25 and 2003-01-05, i.e. 
    possibly with the new parser. 3.3 is ok.
    
    A backtrace shows this:
    #0  0x08104253 in type_unknown_p (exp=0x4017bf30)
        at ../../gcc-3.4-CVS/gcc/cp/typeck.c:191
    #1  0xbfffeac8 in ?? ()
    #2  0x080e039e in arg_assoc (k=0xbfffeb20, n=0x4018b884)
        at ../../gcc-3.4-CVS/gcc/cp/decl2.c:4001
    #3  0x080e0325 in arg_assoc_args (k=0xbfffeb20, args=0x4018b884)
        at ../../gcc-3.4-CVS/gcc/cp/decl2.c:3985
    #4  0x080e0826 in lookup_arg_dependent (name=0x4015b580, fns=0x401902f4, 
        args=0x0) at ../../gcc-3.4-CVS/gcc/cp/decl2.c:4089
    #5  0x080f2825 in cp_parser_postfix_expression (parser=0x40192080, 
        address_p=false) at ../../gcc-3.4-CVS/gcc/cp/parser.c:3948
    
    From there I don't know further, of course.
    
    W.
Comment 2 s.bosscher 2003-02-20 21:51:23 UTC
From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: bkoz@redhat.com, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
	nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org, stefan@snon.net
Cc:  
Subject: Re: c++/9779: [3.4 regression] ICE in type_unknown_p when casting
 in static member
Date: Thu, 20 Feb 2003 21:51:23 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9779
 
 devphil says:
 
 : Search converges between 2002-12-27-trunk (#85) and 2002-12-28-trunk 
 (#86).
 
 
 Line-numbered input is:
 ========================================
      1  void *malloc(unsigned int size);
      2  template<int> void foo() {
      3    malloc (sizeof (int));
      4  }
      5  template void foo<1>();
      6 
 
 ========================================
 
 
 Diagnostic output follows, from the last compiler tested:
 input: In function `void foo()':
 input:3: internal compiler error: Segmentation fault
 Please submit a full bug report,
 with preprocessed source if appropriate.
 See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
 
 Compiler output follows, from the last compiler tested:
         .file   "input"
 
 So, 99% sure that this is caused by the new parser.
 
 Greetz
 Steven
Comment 3 Andrew Pinski 2003-06-07 15:53:20 UTC
still happens on the mainline (20030607).
Comment 4 Volker Reichelt 2003-07-01 14:30:13 UTC
Maybe related to PR 9907.
Comment 5 CVS Commits 2003-07-02 09:36:24 UTC
Subject: Bug 9779

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2003-07-02 09:36:20

Modified files:
	gcc/cp         : ChangeLog decl2.c typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: dependent-expr1.C 

Log message:
	cp:
	PR c++/9779
	* decl2.c (arg_assoc_class): Don't die on NULL type.
	* typeck.c (type_unknown_p): Don't die on untyped expressions.
	testsuite:
	PR c++/9779
	* g++.dg/template/dependent-expr1.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3481&r2=1.3482
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.635&r2=1.636
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.469&r2=1.470
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2826&r2=1.2827
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/dependent-expr1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 6 Nathan Sidwell 2003-07-02 09:42:41 UTC
	PR c++/9779
	* decl2.c (arg_assoc_class): Don't die on NULL type.
	* typeck.c (type_unknown_p): Don't die on untyped expressions.