public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28445]  New: Fault to compile correct template code
@ 2006-07-20 12:17 keithwilliams333 at gmail dot com
  2006-07-20 12:49 ` [Bug c++/28445] " rguenth at gcc dot gnu dot org
  2006-07-20 13:26 ` keithwilliams333 at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: keithwilliams333 at gmail dot com @ 2006-07-20 12:17 UTC (permalink / raw)
  To: gcc-bugs

Compilier version:
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr
--exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs --without-x
--enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter
--disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm
--disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization
--enable-libstdcxx-debug : (reconfigured)
Thread model: posix
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)


Also occurs on compiler version:
Using built-in specs.
Configured with FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.4 [FreeBSD] 20050518


Compiler build options:
Default compiler build on FreeBSD 6.1 and cygwin.


Complete command line that triggers the bug:
g++ -save-temps -Wall -pedantic -c -o fault.o fault.cpp

Source code:
You asked for preprocessed file, but the form won't accept it.  This file is
fault.cpp and uses a single language header file.

#include <list>

//---------------------------------------------------------------------------

class CursesTraits
{
public:
        typedef int             line_t;
};


//---------------------------------------------------------------------------

template <typename TraitsT>
class CursesWindow
{
public:
        typedef TraitsT traits_t;
        typedef typename TraitsT::line_t        line_t;
};

typedef CursesWindow<CursesTraits>      curses_window_t;


//---------------------------------------------------------------------------

template <typename WindowT, typename TraitsT>
class Snake
{
public:
        typedef TraitsT traits_t;
        typedef typename TraitsT::line_t        line_t;

        void    Draw();

private:
        struct Point
        {
                Point(line_t defy = 1, line_t defx = 1) : x(defx), y(defy) {}

                line_t  x;
                line_t  y;
        };

        typedef std::list<Point> points_t;

        std::list<Point>        m_points;
};

typedef Snake<curses_window_t, curses_window_t::traits_t> snake_t;


template <typename WindowT, typename TraitsT>
inline
void Snake<WindowT, TraitsT>::Draw()
{
        for (points_t::const_iterator p = m_points.begin(); p !=
m_points.end(); ++p)
        {
                int x = p->x;
                int y = p->y;
        }
}


//---------------------------------------------------------------------------

class Game
{
public:
        ~Game();

        void    Draw();

private:
        typedef std::list<snake_t*>     snake_list_t;

        snake_list_t    m_snakes;
};

void Game::Draw()
{
        for (snake_list_t::iterator p = m_snakes.begin(); p != m_snakes.end();
++p)
                (*p)->Draw();
}

Game::~Game()
{
        for (snake_list_t::iterator p = m_snakes.begin(); p != m_snakes.end();
++p)
                delete *p;
}


//---------------------------------------------------------------------------

int main()
{
        Game    game;
        game.Draw();

        return 0;
}


-- 
           Summary: Fault to compile correct template code
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: keithwilliams333 at gmail dot com


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/28445] Fault to compile correct template code
  2006-07-20 12:17 [Bug c++/28445] New: Fault to compile correct template code keithwilliams333 at gmail dot com
@ 2006-07-20 12:49 ` rguenth at gcc dot gnu dot org
  2006-07-20 13:26 ` keithwilliams333 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-07-20 12:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-07-20 12:48 -------
The code is invalid.  points_t::const_iterator is a dependent type which you
need to prefix with 'typename '.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/28445] Fault to compile correct template code
  2006-07-20 12:17 [Bug c++/28445] New: Fault to compile correct template code keithwilliams333 at gmail dot com
  2006-07-20 12:49 ` [Bug c++/28445] " rguenth at gcc dot gnu dot org
@ 2006-07-20 13:26 ` keithwilliams333 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: keithwilliams333 at gmail dot com @ 2006-07-20 13:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from keithwilliams333 at gmail dot com  2006-07-20 13:26 -------
(In reply to comment #1)
> The code is invalid.  points_t::const_iterator is a dependent type which you
> need to prefix with 'typename '.
> 

I've seen the error of my ways.
Thanks.


-- 


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-20 13:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-20 12:17 [Bug c++/28445] New: Fault to compile correct template code keithwilliams333 at gmail dot com
2006-07-20 12:49 ` [Bug c++/28445] " rguenth at gcc dot gnu dot org
2006-07-20 13:26 ` keithwilliams333 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).