public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43382]  New: Internal error on C++0x code
@ 2010-03-15 20:14 chris at bubblescope dot net
  2010-03-15 23:56 ` [Bug c++/43382] ICE " paolo dot carlini at oracle dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: chris at bubblescope dot net @ 2010-03-15 20:14 UTC (permalink / raw)
  To: gcc-bugs

The following code causes an assert on a recent svn g++, with -std=c++0x. On
g++ 4.4 it produces an error. I believe the code to be valid, but am not 100%
positive.

#include <vector>

struct Range
{
        int lb;
        int ub;
        Range(int i, int j) : lb(i), ub(j) {}
        Range(const Range& r) = default;
        Range() = default;
};

template<class T>
T deref(const T& t)
{ return t; }

template <class T, template <typename T, typename...> class Cont,
          class... Args>
auto
deref(const Cont<T>& u, int i, Args... args)
-> decltype(deref(u[i], args...))
{ deref(u[i], args...); }

template <class T, template <typename T, typename...> class Cont,
          class... Args>
auto
deref(const Cont<T>& u, Range r, Args... args)
-> Cont<decltype(deref(u[0], args...))>
{
        typedef decltype(deref(u[0], args...)) member;
        Cont<member> retval;
        for(int i = r.lb; i <= r.ub; ++i)
        {
                retval.push_back(deref(u[i], args...));
        } 
        return retval;
}



int main(void)
{
        std::vector<std::vector<std::vector<int>>> v;
        int i = deref(v, 1,2,3);
        std::vector<int> j = deref(v, 1, Range(1,2), 3);
}


-- 
           Summary: Internal error on C++0x code
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: chris at bubblescope dot net


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


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

end of thread, other threads:[~2010-05-26 17:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
2010-03-15 23:56 ` [Bug c++/43382] ICE " paolo dot carlini at oracle dot com
2010-03-16  8:39 ` chris at bubblescope dot net
2010-03-16 10:28 ` paolo dot carlini at oracle dot com
2010-03-16 11:51 ` rguenth at gcc dot gnu dot org
2010-05-26  4:59 ` [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates jason at gcc dot gnu dot org
2010-05-26 15:00 ` jason at gcc dot gnu dot org
2010-05-26 15:19 ` jason at gcc dot gnu dot org
2010-05-26 17:15 ` jason at gcc dot gnu dot org

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).