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]

c++/6649: implicit typename warning suggests action that leads to a syntax error



>Number:         6649
>Category:       c++
>Synopsis:       implicit typename warning suggests action that leads to a syntax error
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 13 09:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Gianni Mariani
>Release:        gcc 3.1 pre release
>Organization:
>Environment:
Red Hat 7.2
>Description:
If I follow the suggestions from the compiler and place a 'typename' in the given place ( see where the TYPENAME_SYNTAX_ERROR macro expands) the gcc 3.1 compiler complains that it's a syntax error to do so. The code below is demonstrates this - uncomment the 'typename' keyword from the macro to demonstrate the compiler's syntax error report or leave it commented and experience a warning.


#============= snip =======================

#include <list>

template< class client_base, class service_base>
class TMPL_A;

template< class client_base, class service_base>
class TMPL_B;

template< class client_base, class service_base>
class TMPL_C {
 public:

   typedef TMPL_A< client_base,service_base> * t_elem_type;

   typedef std::list< t_elem_type >            t_x_list;

   typedef typename t_x_list::iterator         t_x_iter;

   typedef typename std::list< t_x_iter >      t_x_iter_list;

   typedef typename t_x_iter_list::iterator    t_x_iter_iter;

};


// ======== TMPL_A ===============================
/**
*  TMPL_A is a template for Service handler for
*  a client.
*  */

template< class client_base, class service_base>
class TMPL_A
 : public client_base,
   public TMPL_C<client_base,service_base>
{
public:

#define TYPENAME_SYNTAX_ERROR //typename

// define some members

   TYPENAME_SYNTAX_ERROR t_x_iter            m_my_iter;

   TMPL_B<client_base,service_base>        * m_my_service;

   // some more stuff goes here

};

>How-To-Repeat:

Take the code in the description and compile it with gcc 3.1PR with warning turned on. The compiler will warn about implicit typename use being depricated, adding typename (by removing the // in from of typename in the #define) yields a syntax error.

This is a violation of the Gianni rule for compilers :
A compiler must not generate a warning that will lead to worse errors.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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