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++/28445] New: Fault to compile correct template code


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


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