Bug 5533 - g++ segfaults when processing std::accumulate(begin, end, init, invalid_op)
Summary: g++ segfaults when processing std::accumulate(begin, end, init, invalid_op)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.0.2
: P3 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
: 5532 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-01-29 07:36 UTC by mathias.hasselmann
Modified: 2003-08-06 17:40 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
accum.ii (84.96 KB, text/x-c++)
2003-05-21 15:16 UTC, mathias.hasselmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mathias.hasselmann 2002-01-29 07:36:02 UTC
Duh, sorry: Invalid attachement...

g++ segfaults when it has to processing std::accumulate(begin, end, init, invalid_op) where invalid_op is a invalid template reference.

Release:
3.0.2

Environment:
System: Linux dali.sqx.lde 2.4.9-mosix #17 SMP Sam Sep 1 03:04:51 CEST 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /nfs/sam/opt/glibc/gcc-3.0.2/configure --prefix=/usr

How-To-Repeat:
See the attachement for preprocessed code. Here comes the plain code:

$ cat accum.cc
#include<iostream>
#include<numeric>
#include<functional>

int main()
{
    int nums[] = { 1, 2, 3, 4, 5 };
    
    std::cout << std::accumulate(nums, nums + sizeof(nums)/sizeof(*nums),
                                 0, std::plus) << std::endl;
}
$ LC_ALL=C g++ -save-temps accum.cc 
accum.cc: In function `int main()':
accum.cc:10: Internal 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.
$
Comment 1 mathias.hasselmann 2002-01-29 07:36:02 UTC
Fix:
no idea
Comment 2 Volker Reichelt 2002-01-31 17:03:22 UTC
From: Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, mathias.hasselmann@gmx.de,
        nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/5533: g++ segfaults when processing std::accumulate(begin, end, init, invalid_op)
Date: Thu, 31 Jan 2002 17:03:22 +0100

 Hi,
 
 the problem can be reduced to the following test-example:
 
 namespace N
 {
   template <class T> struct A{};
 }
 
 template <class T> void f(T) {}
 
 void g() { f(N::A); } // illegal
 
 This crashes under i686-pc-linux-gnu and mips-sgi-irix6.5 with
 gcc 2.95.3 (and probably earlier), 3.0.x and 3.1 (as of 20020128).
 
 Greetings,
 Volker Reichelt
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5533
 
 
Comment 3 Kriang Lerdsuwanakij 2002-05-28 07:21:11 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
Comment 4 Volker Reichelt 2002-12-30 14:01:26 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in gcc 3.4 with the new parser.
Comment 5 Volker Reichelt 2003-01-22 23:21:51 UTC
From: reichelt@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/5533
Date: 22 Jan 2003 23:21:51 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	reichelt@gcc.gnu.org	2003-01-22 23:21:51
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/parse: ret-type1.C tmpl-outside1.C 
 	                            int-as-enum1.C no-typename1.C 
 	                            no-value1.C wrong-inline1.C ref1.C 
 	                            attr-ctor1.C namespace5.C 
 	                            func-def1.C undefined1.C 
 	                            specialization1.C struct-as-enum1.C 
 	                            undefined2.C 
 
 Log message:
 	PR c++/2738
 	* g++.dg/parse/ret-type1.C: New test.
 	
 	PR c++/3792
 	* g++.dg/parse/tmpl-outside1.C: New test.
 	
 	PR c++/4207
 	* g++.dg/parse/int-as-enum1.C: New test.
 	
 	PR c++/4903
 	* g++.dg/parse/no-typename1.C: New test.
 	
 	PR c++/5533
 	* g++.dg/parse/no-value1.C: New test.
 	
 	PR c++/5921
 	* g++.dg/parse/wrong-inline1.C: New test.
 	
 	PR c++/6402
 	* g++.dg/parse/ref1.C: New test.
 	
 	PR c++/6992
 	* g++.dg/parse/attr-ctor1.C: New test.
 	
 	PR c++/7229
 	* g++.dg/parse/namespace5.C: New test.
 	
 	PR c++/7917
 	* g++.dg/parse/func-def1.C: New test.
 	
 	PR c++/8143
 	* g++.dg/parse/undefined1.C: New test.
 	
 	PR c++/5723, PR c++/8522
 	* g++.dg/parse/specialization1.C: New test.
 	
 	PR c++/163, PR c++/8595
 	* g++.dg/parse/struct-as-enum1.C: New test.
 	
 	PR c++/9173
 	* g++.dg/parse/undefined2.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2361&r2=1.2362
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/ret-type1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/tmpl-outside1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/int-as-enum1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/no-typename1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/no-value1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/wrong-inline1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/ref1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/attr-ctor1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/namespace5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/func-def1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/undefined1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/specialization1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/struct-as-enum1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/undefined2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Comment 6 Volker Reichelt 2003-07-17 09:40:12 UTC
Now also fixed on the 3.3 branch.
Most likely by the patch for PR 10558.