public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67247] New: ICE on std::forward args&& inside nested lambda function
@ 2015-08-17 10:43 tower120 at gmail dot com
  2015-08-17 11:03 ` [Bug c++/67247] " trippels at gcc dot gnu.org
  2015-08-19  9:29 ` mpolacek at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tower120 at gmail dot com @ 2015-08-17 10:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67247

            Bug ID: 67247
           Summary: ICE on std::forward args&& inside nested lambda
                    function
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tower120 at gmail dot com
  Target Milestone: ---

Code as is:
http://coliru.stacked-crooked.com/a/903e76d5446bfeb2
----------------------------------------------------------------
#include <iostream>
#include <tuple>

#include <utility>

template <class F1, class F2>
decltype(auto) operator >> (F1 &&f1, F2 &&f2){
    using namespace std;
    return f2(forward<F1>(f1));
}

template <class F1, class F2>
decltype(auto) operator << (F1 &&f1, F2 &&f2){
    using namespace std;
    return f1(forward<F2>(f2));
}


// curry 2 args pack (temporary)
#define f(...) \
    [](auto&& ...args1){return  \
        [&](auto&& ...args2){return __VA_ARGS__
(std::forward<decltype(args1)>(args1)..., args2...);} ;  /* <-- ICE HERE!*/ \ 
    }


using namespace std;

auto sum(int a, int b){
    return a+b;
}

auto divide(int a, int b){
    return a/b;
}


int main() {
    float a = 10;
    float b = 20;

    auto part1 =  f(divide) << 5;          // just for test purpose

    auto res = sum(a,b) >> f(divide) << 5;

    auto res_ctrl = divide(sum(a,b), 5.0);


    cout << "res : "<< res << endl;
    cout << "ctrl: "<< res_ctrl << endl;

    return 0;
}

----------------------------------------------------------------

C:\Dropbox\C++\exp_chained_call\simple_chain.h:22:49: internal compiler error:
Segmentation fault
         [&](auto&& ...args2){return __VA_ARGS__
(std::forward<decltype(args1)>(args1)..., args2...);} ; \

Without std::forward<decltype(args1)> it is ok.
With [&](auto&& ...args2){return __VA_ARGS__ (args1...,
std::forward<decltype(args2)>(args2)...);} ; ok also.


P.S. I just realize, that args1 is probably stored as &, not && inside
lambda... But ICE is ICE.


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

end of thread, other threads:[~2015-08-19  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-17 10:43 [Bug c++/67247] New: ICE on std::forward args&& inside nested lambda function tower120 at gmail dot com
2015-08-17 11:03 ` [Bug c++/67247] " trippels at gcc dot gnu.org
2015-08-19  9:29 ` mpolacek 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).