[Bug c++/22227] New: g++ 4.0.0 has issues with the typedef of reference

jcurran2 at uiuc dot edu gcc-bugzilla@gcc.gnu.org
Tue Jun 28 22:31:00 GMT 2005


G++ thinks that a nested type is a nested class and it expects a constructor, 
destructor, or type conversion before the object referenced in the class is 
processed when compiling a function of a nested type defined in the header file 
of a templated class.

Header file below

//C++ STL classes have 12 type definitions, so that every class
//   defines the following type names as nested types:
//
//      value_type, pointer, reference, const_pointer, const_reference
//        iterator, const_iterator, reverse_iterator, const_reverse_iterator
//          allocator_type, size_type, diference_type

typedef Etype& reference; //list<...>::value_type to access
                          //whatever type this list holds


template <class Etype>
typename list<Etype>::reference 
                        list<Etype>::const_iterator*() const
{
    return ptr->element;
}

The compiler complains on the line containing list<Etype>::const_iterator*() 
const and it says 

error: expected constructor, destructor, or type conversion before 'list'

This particular functions implementation was written by my Data Structures and 
Software Principles professor, Jason Zych, a Computer Science Professor at the 
University of Illinois at Urbana-Champaign.  The code works perfectly fine 
using the University's Sun CC(C++) compiler on their Sun Machines.  The CC 
compiler is included in Sun Microsystem's Sun Studio 9 for Solaris.  However, I 
want to be able to compile my code on my home pc and my laptop and right now 
the best option for me is to use g++ since Sun does not include its CC compiler 
in the Linux version of Solaris 9 and the Solaris version of Sun Studio costs 
$1000 plus the Sun sparc hardware needed to run it is quite expensive.  I 
recently updated from GCC 3.3.3 to GCC 4.0.0 with an update to Fedora Core 4 
from Fedora Core 3 and the problem occurs using the latest release of GCC.  I 
hope that the next update to GCC will include a fix to this bug and that it 
will be released as soon as possible.

-- 
           Summary: g++ 4.0.0 has issues with the typedef of reference
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jcurran2 at uiuc dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list