This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15329] New: ICE on constructor of member template


This code produces an ICE with g++-3.4.0

class Canvas
{
public:
  typedef void (Canvas::* Manip)();

  template <Manip doit>
  class Saver
  {
  public:
    Saver(Canvas& canvas) :
      itsCanvas(canvas)
    {
      (itsCanvas.*doit)(); // ICE occurs here; no ICE if 'canvas' is used
instead of 'itsCanvas'
    }

  private:
    Canvas& itsCanvas;
  };
};


Specs:
[sideswipe 18:20 52]$ /usr/local/gcc-3.4.0/bin/g++ -v
Reading specs from /usr/local/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: /home/rjpeters/build/gcc-3.4.0/configure
--prefix=/usr/local/gcc-3.4.0 --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.4.0

There is no ICE with g++-3.3.2 for the same code and as far as I can recall
there has been no problem with this same code as I upgraded through all
successive versions including 3.1.x, 3.2.x, and 3.3.x.

There is no ICE if the problem line uses the function argument 'canvas' rather
than the member variable 'itsCanvas' as the callee of the ptr-to-memfunc.

There is no ICE if the problem line is changed to a direct member-function call
rather than a call through a ptr-to-memfunc and in this case the nested class is
not a template class:

class Canvas
{
public:
  void foo();

  class Saver
  {
  public:
    Saver(Canvas& canvas) :
      itsCanvas(canvas)
    {
      itsCanvas.foo(); // no ICE here in this case
    }

  private:
    Canvas& itsCanvas;
  };
};

-Rob Peters

-- 
           Summary: ICE on constructor of member template
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rjpeters at klab dot caltech dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15329


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]