public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rafal at rawicki dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/59721] New: [4.8 Regression] std::bind nested more than one level results in infinite template substitution
Date: Wed, 08 Jan 2014 13:44:00 -0000	[thread overview]
Message-ID: <bug-59721-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 59721
           Summary: [4.8 Regression] std::bind nested more than one level
                    results in infinite template substitution
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rafal at rawicki dot org

Consider following code:

#include <functional>
#include <iostream>

struct A
{
    struct B
    {
        struct C
        {
            C(): m(5){}
            int m;
        } c;
    } b;
};

int main()
{
    A::B b;

    auto extractor = std::bind(&A::B::C::m, std::bind(&A::B::c,
std::placeholders::_1));
    std::cout << extractor(b) << std::endl;

    A a;
    auto extractor2 = std::bind(&A::B::C::m, std::bind(&A::B::c,
std::bind(&A::b, std::placeholders::_1)));
    std::cout << extractor2(a) << std::endl;

    return 0;
}

Under g++-4.7 this code compiles correctly:
$ g++-4.7 -Wall -Wextra -std=c++11 bind.cpp -o bind && ./bind
5
5

while under g++-4.8 it generates infinite template recursion:
$ g++-4.8 -Wall -Wextra -std=c++11 bind.cpp -o bind 2>&1 | head
In file included from bind.cpp:1:0:
/usr/include/c++/4.8/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 = A&]’
  -> decltype(__arg(declval<_Args>()...))
                                   ^
/usr/include/c++/4.8/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<std::_Mem_fn<A::B A::*>(std::_Placeholder<1>)>] [with
_CVArg = const volatile std::_Bind<std::_Mem_fn<A::B
A::*>(std::_Placeholder<1>)>; _Args = {A&}]’
/usr/include/c++/4.8/functional:1391:40:   required by substitution of
‘template<class _CVArg, class ... _Args, long 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 ...}; long unsigned int ..._Indexes = {_Indexes ...}; _Arg =
std::_Bind<std::_Mem_fn<A::B::C A::B::*>(std::_Bind<std::_Mem_fn<A::B
A::*>(std::_Placeholder<1>)>)>] [with _CVArg = std::_Bind<std::_Mem_fn<A::B::C
A::B::*>(std::_Bind<std::_Mem_fn<A::B A::*>(std::_Placeholder<1>)>)>; _Args =
{A&}; long unsigned int ..._Indexes = {0ul}]’
/usr/include/c++/4.8/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 = A&]’
/usr/include/c++/4.8/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<std::_Mem_fn<A::B A::*>(std::_Placeholder<1>)>] [with
_CVArg = const volatile std::_Bind<std::_Mem_fn<A::B
A::*>(std::_Placeholder<1>)>; _Args = {A&}]’
/usr/include/c++/4.8/functional:1391:40:   required by substitution of
‘template<class _CVArg, class ... _Args, long 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 ...}; long unsigned int ..._Indexes = {_Indexes ...}; _Arg =
std::_Bind<std::_Mem_fn<A::B::C A::B::*>(std::_Bind<std::_Mem_fn<A::B
A::*>(std::_Placeholder<1>)>)>] [with _CVArg = std::_Bind<std::_Mem_fn<A::B::C
A::B::*>(std::_Bind<std::_Mem_fn<A::B A::*>(std::_Placeholder<1>)>)>; _Args =
{A&}; long unsigned int ..._Indexes = {0ul}]’
/usr/include/c++/4.8/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 = A&]’

My g++ is:
$ g++-4.8 --version
g++-4.8 (Ubuntu/Linaro 4.8.2-8) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>From gcc-bugs-return-439634-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Jan 08 13:46:35 2014
Return-Path: <gcc-bugs-return-439634-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22393 invoked by alias); 8 Jan 2014 13:46:34 -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 22365 invoked by uid 48); 8 Jan 2014 13:46:31 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/59722] [4.9 Regression] Bootstrap comparison failure on i686-linux
Date: Wed, 08 Jan 2014 13:46:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: ipa
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on target_milestone everconfirmed
Message-ID: <bug-59722-4-nWBWpBwkTH@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59722-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59722-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: 2014-01/txt/msg00776.txt.bz2
Content-length: 459

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-01-08
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1


             reply	other threads:[~2014-01-08 13:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 13:44 rafal at rawicki dot org [this message]
2014-01-08 14:34 ` [Bug libstdc++/59721] " redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-59721-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).