public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59360] New: Complicated bind expression causing infinite recursive template instantiations
@ 2013-12-01 16:05 eric.niebler at gmail dot com
  2014-01-08 15:43 ` [Bug c++/59360] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: eric.niebler at gmail dot com @ 2013-12-01 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59360
           Summary: Complicated bind expression causing infinite recursive
                    template instantiations
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com

This code compiles with clang 3.3 but doesn't compile with gcc 4.8.2 with
-std=gnu++11:

    #include <vector>
    #include <functional>
    #include <utility>
    #include <iterator>
    #include <algorithm>

    constexpr struct adjacent_finder
    {
        template<typename Rng>
        typename Rng::const_iterator
        operator()(Rng const & rng) const
        {
            return std::adjacent_find(rng.begin(), rng.end());
        }
    } adjacent_find {};

    constexpr struct ranger
    {
        template<typename It>
        std::pair<It, It>
        operator()(It begin, It end) const
        {
            return std::make_pair(begin, end);
        }
    } range {};

    constexpr struct prever
    {
        template<typename It>
        It operator()(It begin) const
        {
            return std::prev(begin);
        }
    } prev {};

    constexpr struct ender
    {
        template<typename Rng>
        typename Rng::const_iterator
        operator()(Rng const & rng) const
        {
            return rng.end();
        }
    } end {};

    int main()
    {
        using std::placeholders::_1;

        auto fun = std::bind(
            range,
            std::bind(adjacent_find, _1),
            std::bind(prev, std::bind(end, _1))
        );

        std::vector<int> vi;
        fun(vi);
    }

From the error backtrace:

In file included from test2.cpp:2:0:
/usr/local/gcc-4.8.2/include/c++/4.8.2/functional:1138:35: error: template
instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase
the maximum) substituting ‘template<class _Tp> typename
std::add_rvalue_reference< <template-parameter-1-1> >::type std::declval()
[with _Tp = std::vector<int>&]’
  -> decltype(__arg(declval<_Args>()...))
                                   ^
/usr/local/gcc-4.8.2/include/c++/4.8.2/functional:1391:40:   recursively
required by substitution of ‘template<class _CVArg, class ... _Args> decltype
(__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&,
std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args
...}; _Arg = std::_Bind<ender(std::_Placeholder<1>)>] [with _CVArg = const
volatile std::_Bind<ender(std::_Placeholder<1>)>; _Args = {std::vector<int,
std::allocator<int> >&}]’
/usr/local/gcc-4.8.2/include/c++/4.8.2/functional:1391:40:   required by
substitution of ‘template<class _CVArg, class ... _Args, unsigned int
..._Indexes> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true,
false>::__call(_CVArg&, std::tuple<_Args2 ...>&, const
std::_Index_tuple<_Indexes ...>&) const volatile [with _CVArg = _CVArg; _Args =
{_Args ...}; unsigned int ..._Indexes = {_Indexes ...}; _Arg =
std::_Bind<prever(std::_Bind<ender(std::_Placeholder<1>)>)>] [with _CVArg =
std::_Bind<prever(std::_Bind<ender(std::_Placeholder<1>)>)>; _Args =
{std::vector<int, std::allocator<int> >&}; unsigned int ..._Indexes = {0u}]’
/usr/local/gcc-4.8.2/include/c++/4.8.2/functional:1143:50:   template
instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase
the maximum) substituting ‘template<class _Tp> typename
std::add_rvalue_reference< <template-parameter-1-1> >::type std::declval()
[with _Tp = std::vector<int>&]’

[rest snipped...]
>From gcc-bugs-return-436359-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Dec 01 16:10:09 2013
Return-Path: <gcc-bugs-return-436359-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 14927 invoked by alias); 1 Dec 2013 16:10:09 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 14897 invoked by uid 48); 1 Dec 2013 16:10:06 -0000
From: "eric.niebler at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59361] New: cannot expand parenthesized pack expression
Date: Sun, 01 Dec 2013 16:10:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: eric.niebler at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-59361-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg00014.txt.bz2
Content-length: 1233

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

            Bug ID: 59361
           Summary: cannot expand parenthesized pack expression
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com

The following compiles with clang but doesn't with g++ 4.8.2 with -std=gnu++11:

    template<bool ...Bs>
    struct and_ 
    {
        constexpr static bool value{true};
    };

    template<typename T>
    struct true_
    {
        constexpr operator bool() const { return true; }
    };

    template<typename ...Ts>
    constexpr bool foo(Ts...)
    {
        return and_<(true_<Ts>())...>::value;
    }

    int main()
    {
    }

The error I get is:

test.cpp: In function ‘constexpr bool foo(Ts ...)’:
test.cpp:16:34: error: expected parameter pack before ‘...’
         return and_<(true_<Ts>())...>::value;
                                  ^
test.cpp:16:37: error: template argument 1 is invalid
         return and_<(true_<Ts>())...>::value;
                                     ^
>From gcc-bugs-return-436360-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Dec 01 16:26:21 2013
Return-Path: <gcc-bugs-return-436360-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22672 invoked by alias); 1 Dec 2013 16:26:20 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 22639 invoked by uid 48); 1 Dec 2013 16:26:14 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59360] Complicated bind expression causing infinite recursive template instantiations
Date: Sun, 01 Dec 2013 16:26:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59360-4-98bz4gqBca@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59360-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59360-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg00015.txt.bz2
Content-length: 144

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY360

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
another dup of PR 57899 ?


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

* [Bug c++/59360] Complicated bind expression causing infinite recursive template instantiations
  2013-12-01 16:05 [Bug c++/59360] New: Complicated bind expression causing infinite recursive template instantiations eric.niebler at gmail dot com
@ 2014-01-08 15:43 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-08 15:43 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
dup

*** This bug has been marked as a duplicate of bug 57899 ***


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

end of thread, other threads:[~2014-01-08 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-01 16:05 [Bug c++/59360] New: Complicated bind expression causing infinite recursive template instantiations eric.niebler at gmail dot com
2014-01-08 15:43 ` [Bug c++/59360] " redi at gcc dot gnu.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).