c++/7701: Inner class scopting not working correctly for function prototype matching

rob@mve.com rob@mve.com
Fri Aug 23 06:36:00 GMT 2002


>Number:         7701
>Category:       c++
>Synopsis:       Inner class scopting not working correctly for function prototype matching
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 23 06:36:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     rob@mve.com
>Release:        gcc 3.1
>Organization:
>Environment:
Red Hat Linux 7.3 on x86 Dual P4 Xeon 2.4 GHz
Linux version 2.4.18-5smp (bhcompile@daffy.perf.redhat.com) (gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)) #1 SMP Mon Jun 10 15:19:40 EDT 2002
>Description:
With multiple levels of inner (nested) classes within an outer class template, attempting to return an instance of one inner class from a member function of an inner, inner class causes a compilation failure with a series of related errors. There is a failure to match function prototypes even though one of the candidates listed is identical to that requested, and all class names have been fully scoped.

In the example file attached the member function of a second degree inner class is attempting to return an object of a first degree inner class, all of which are in the same outer class template. Example class layout:

template <typename N>
class A
{
  class B
  {
  };

  class C
  {
    class D
    {
       A<N>::B operator*(); // Member function declaration
    };
  };
};

template <typename N>
A<N>::B A<N>::C::D::operator*() // Causes errors
{
   return A<N>::B();
}
Note that the same source code provided in the attached file works perfectly with the SGI MipPro C++ compiler. The attached file contains the example on which I discovered the issue. The same problem occurs twice in this code.

The errors reported on my system are:

In file included from main.cxx:8:
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:1373: prototype
   for `Grid2D<N>::PointReference
   Grid2D<N>::FaceReference::VertexCirculator::operator*()' does not match any
   in class `Grid2D<N>::FaceReference::VertexCirculator'
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:257: candidate
   s are: Point<N> Grid2D<N>::FaceReference::VertexCirculator::operator*()
   const
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:256:
         Grid2D<N>::PointReference
   Grid2D<N>::FaceReference::VertexCirculator::operator*()
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:1373: template
   definition of non-template `Grid2D<N>::PointReference
   Grid2D<N>::FaceReference::VertexCirculator::operator*()'
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:1453: prototype
   for `Grid2D<N>::EdgeReference
   Grid2D<N>::FaceReference::EdgeCirculator::operator*()' does not match any in
   class `Grid2D<N>::FaceReference::EdgeCirculator'
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:287: candidate
   s are: Edge<N> Grid2D<N>::FaceReference::EdgeCirculator::operator*() const
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:286:
         Grid2D<N>::EdgeReference
   Grid2D<N>::FaceReference::EdgeCirculator::operator*()
/homes/rob/dev/products/nmove/main/model/egs/grid2d/inc/Grid2D.h:1453: template
   definition of non-template `Grid2D<N>::EdgeReference
   Grid2D<N>::FaceReference::EdgeCirculator::operator*()'
>How-To-Repeat:
The following command line reproduces the error :

/usr/local/gcc3.1/bin/g++ -fPIC -ftemplate-depth-50 -Wno-deprecated -g   -DMVE_DEBUG -DMVE_LINUX -DMVE_WFM   -DMVE_NM  -DMVE_QT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DMVE_CGAL -DMVE_USE_CGAL -DDEBUG -DMVE_BOOST -DMVE_BOOST_VERSION=1280   -DMVE_LINUX_GCC3 -DMVE_STD  -I. -I/homes/rob/dev/products/nmove/main -I/homes/rob/utils_install/LINUX/qt-3.0.3-LINUX.DEBUG.GCC3/include -I/homes/rob/utils_install/LINUX/cgal-2.4-LINUX.DEBUG.GCC3/include/CGAL/config/i686_Linux-2.4.18-5smp_g++-3.1.0 -I/homes/rob/utils_install/LINUX/cgal-2.4-LINUX.DEBUG.GCC3/include -I/homes/rob/utils_install/LINUX/boost-1_28_0-LINUX.DEBUG.GCC3  -c main.cxx -o obj_files/LINUX.DEBUG.GCC3/main.o


>Fix:
None found
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list