Bug 8391 - [regression] infinite loop in cp/decl2.c(finish_file)
[regression] infinite loop in cp/decl2.c(finish_file)
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
3.2
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
: ice-on-valid-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2002-10-29 09:26 UTC by spencer
Modified: 2003-07-25 17:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description spencer 2002-10-29 09:26:01 UTC
The following code causes the compiler to loop infinitely in cc1plus for the targets described above.  

This compiles successfully on other (commercial) compilers.

$ /opt/gcc-3.1.1-cross/sparc-sun-solaris2.8/bin/sparc-sun-solaris2.8-g++ -v
Reading specs from /opt/gcc-3.1.1-cross/sparc-sun-solaris2.8/lib/gcc-lib/sparc-sun-solaris2.8/3.1.1/specs
Configured with: ../../gcc-3.1.1/configure --with-dwarf2 --enable-languages=c,c++ --enable-threads=single --disable-shared --prefix=/opt/gcc-3.1.1-cross/sparc-sun-solaris2.8 --target=sparc-sun-solaris2.8 -v --with-headers=/build/spencer/gcc-cross/sparc-sun-solaris2.8/target-stuff/include/ --with-lib=/build/spencer/gcc-cross/sparc-sun-solaris2.8/target-stuff/lib --with-gnu-as --with-gnu-ld --disable-multilib
Thread model: single
gcc version 3.1.1

$ /opt/gcc-3.2-cross/sparc-sun-solaris2.8/bin/sparc-sun-solaris2.8-g++ -v
Reading specs from /opt/gcc-3.2-cross/sparc-sun-solaris2.8/lib/gcc-lib/sparc-sun-solaris2.8/3.2/specs
Configured with: ../../gcc-3.2/configure --with-dwarf2 --enable-languages=c,c++ --enable-threads=single --disable-shared --prefix=/opt/gcc-3.2-cross/sparc-sun-solaris2.8 --target=sparc-sun-solaris2.8 --with-headers=/build/eng-linux1/spencer/gcc-cross/sparc-sun-solaris2.8/target-stuff/include/ --with-lib=/opt/gcc-3.2-cross/sparc-sun-solaris2.8/sparc-sun-solaris2.8/lib --with-gnu-as --with-gnu-ld --disable-multilib --enable-concept-checks --enable-clocale=ieee_1003.1-2001
Thread model: single
gcc version 3.2

$ g++ -v
Reading specs from /opt/gcc-3.2-cross/i686-pc-linux-gnu/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: ../../gcc-3.2/configure --with-dwarf2 --enable-languages=c,c++ --enable-threads=single --disable-shared --prefix=/opt/gcc-3.2-cross/i686-pc-linux-gnu --with-gnu-as --with-gnu-ld --with-as=/opt/gcc-3.2-cross/i686-pc-linux-gnu/bin/as --with-ld=/opt/gcc-3.2-cross/i686-pc-linux-gnu/bin/ld --disable-multilib --enable-clocale=gnu
Thread model: single
gcc version 3.2

// g++ -Wall -c -O foo.o foo.cc


#include <iostream>
#include <string>

namespace Namespace
{
  class Object
  {
  public:
    Object() {}
    virtual ~Object() {}

  public:
    struct Writer
    {
      virtual bool operator()(const char *data, const size_t size) = 0;
    };

    virtual bool write(Writer &writer) const;
  };

  // convenience output operator
  inline std::ostream &operator<<(std::ostream &out,
                                  const Object &obj)
  {
    class ContentWriter : public Object::Writer
    {
      std::ostream         &m_out;
    public:
      ContentWriter(std::ostream &out)
        : m_out(out)
      {}
      
      virtual bool operator()(const char *data, const size_t size) {
        return m_out.write(data, size);
      }

    } contentWriter(out);
    
    obj.write(contentWriter);
    return out;
  }
}

void
f(Namespace::Object &req)
{
  std::cout << req;
}

Release:
gcc-3.2

Environment:
gcc-3.1.1 sparc-sun-solaris2.8 target on i686-pc-linux-gnu
gcc-3.2 sparc-sun-solaris2.8 target on i686-pc-linux-gnu
gcc-3.2  native

How-To-Repeat:
Compile the file.  The compilation never completes.
Comment 2 Paolo Carlini 2002-10-29 10:19:04 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed on i686-pc-linux-gnu, both mainline and 3_2-branch.
    Regression from 2.95.x and 3.0.x -> high priority.
Comment 3 Wolfgang Bangerth 2002-10-29 12:31:04 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: optimization/8391: [regression] infinite loop in cp/decl2.c(finish_file)
Date: Tue, 29 Oct 2002 12:31:04 -0600 (CST)

 Ack, somehow gnats only picked up my name change, but not the analysis:
 
 Confirmed with both 3.2.1pre and CVS. The infinite loop 
 appears in cp/decl2.c(finish_file), in the 
 do...while(reconsider) loop. "reconsider" is continuously 
 re-set to 1 in line 3512 (in the 3.2.1 branch).
 
 A smaller, self-contained example is this:
 --------------------------------
 struct Outer {
     struct Inner { virtual bool f() = 0; };
     void g(Inner &) const;
 };
 
 
 inline void h(const Outer &o)
 {
   struct Local : public Outer::Inner {
       virtual bool f() {};
   };
   Local l;
   o.g(l);
 }
 
 
 void f(Outer &req) {
   h (req);
 }
 
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 

Comment 4 Mark Mitchell 2002-11-01 17:17:19 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in GCC 3.2.1.
Comment 5 Mark Mitchell 2002-11-02 00:57:26 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8391
Date: 2 Nov 2002 00:57:26 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-11-01 16:57:26
 
 Modified files:
 	gcc            : ChangeLog toplev.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/opt: local1.C 
 
 Log message:
 	PR c++/8391
 	* toplev.c (rest_of_compilation): Do not refuse to output code for
 	an inline function in a local class.
 	
 	PR c++/8391
 	* g++.dg/opt/local1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.116&r2=1.13152.2.657.2.117
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.574.2.16.2.2&r2=1.574.2.16.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.44&r2=1.1672.2.166.2.45
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/local1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 

Comment 6 Mark Mitchell 2002-11-02 00:57:26 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8391
Date: 2 Nov 2002 00:57:26 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-11-01 16:57:26
 
 Modified files:
 	gcc            : ChangeLog toplev.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/opt: local1.C 
 
 Log message:
 	PR c++/8391
 	* toplev.c (rest_of_compilation): Do not refuse to output code for
 	an inline function in a local class.
 	
 	PR c++/8391
 	* g++.dg/opt/local1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.116&r2=1.13152.2.657.2.117
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.574.2.16.2.2&r2=1.574.2.16.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.44&r2=1.1672.2.166.2.45
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/local1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 

Comment 7 Mark Mitchell 2002-11-02 01:03:03 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8391
Date: 2 Nov 2002 01:03:03 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-11-01 17:03:03
 
 Modified files:
 	gcc            : ChangeLog toplev.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/opt: local1.C 
 
 Log message:
 	PR c++/8391
 	* toplev.c (rest_of_compilation): Do not refuse to output code for
 	an inline function in a local class.
 	
 	PR c++/8391
 	* g++.dg/opt/local1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.15839&r2=1.15840
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&r1=1.687&r2=1.688
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2194&r2=1.2195
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/local1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
 

Comment 8 Mark Mitchell 2002-11-02 01:03:03 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8391
Date: 2 Nov 2002 01:03:03 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-11-01 17:03:03
 
 Modified files:
 	gcc            : ChangeLog toplev.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/opt: local1.C 
 
 Log message:
 	PR c++/8391
 	* toplev.c (rest_of_compilation): Do not refuse to output code for
 	an inline function in a local class.
 	
 	PR c++/8391
 	* g++.dg/opt/local1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.15839&r2=1.15840
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&r1=1.687&r2=1.688
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2194&r2=1.2195
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/local1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2