[Bug c++/40512] New: Compilation stops on valid code with ICE

gcc-bugzilla at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sun Jun 21 21:32:00 GMT 2009


        compile the attached code with the -std=c++0x flag.

Environment:
System: Linux x 2.6.26-2-686 #1 SMP Thu Mar 26 01:08:11 UTC 2009 i686 GNU/Linux



host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure --prefix=/home/x/gcc-4.4-20090616
--enable-languages=,c,c++,

How-To-Repeat:
template <unsigned width, unsigned height, typename T>
class M {
                T v;
        public:
                T & operator[](unsigned) { return v; } 
                T const & operator[](unsigned) const { return v; }

                template <typename oT, unsigned owidth>
                auto mggggg(M<owidth, width, oT> o)
                -> M<owidth, height, decltype(T()*o[0])>
                {
                        typedef M<owidth, height, decltype(T()*oT())> res_t;
                        return res_t();
                }
                template <typename oT, unsigned owidth>
                auto operator*(M<owidth, width, oT> const & o) const
                        -> M<owidth, height, decltype(T()*oT())>
                {
                        typedef M<owidth, height, decltype(T()*oT())> res_t;
                        return res_t();
                }
};

int main(int, char *[])
{
        typedef M<2, 2, int> xt;
        M<3, 2, xt> hv;
        M<4, 3, xt> vv;
        hv.mggggg(vv);
}


------- Comment #1 from pooly at ural2 dot hszk dot bme dot hu  2009-06-21 21:32 -------
Fix:
        Replace o[0] with oT() on line 10.


-- 
           Summary: Compilation stops on valid code with ICE
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pooly at ural2 dot hszk dot bme dot hu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list