This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
+ /* relayout again -- to allow for implicit + * parameters to have been added to the capture if it was a + * 'default capture' -- note that this would not be necessary if + * the stack-pointer variant was implemented -- since the layout + * would be known. + * Relayingout here might have nasty effect if one were to query + * sizeof *this from within the body -- would that even be + * possible -- *this would refer to the lambda or the enclosing + * class instance -- if there was one.??? + * + * NOTE: I think this is a redefinition error; I'm just faking that + * it isn't by clearing the size node... need to use stack pointer + * method. But that will likely bring its own issues -- not with + * class layout though. + */ + TYPE_SIZE (type) = NULL_TREE; + finish_struct_1 (type);
The way 'default reference capture' is implemented on the lambda branch seems to be kind of reactive. I would expect
that inheriting the stack somehow (maybe using just a stack pointer) would be better but without more investigation I
don't know if that is possible or how one would go about doing it.
/*
* Rather than looping through the identifiers used in the scope of
* the lambda and synthesizing individual captures of them, it would
* be better to ref the stack frame as transparently as possible...
* e.g. given just three ints i, j and k in scope:
* Instead of transforming:
*
* [&] { i = 1; j = 2; k = 3; };
*
* into
*
* [&i,&j,&k] { i = 1; j = 2; k = 3; };
*
* and thus storing three pointers to int, transform it into:
*
* [sp=enclosing-stack-pointer] { var-from-stack(i,sp) = 1;
* var-from-stack(j,sp) = 2;
* var-from-stack(k,sp) = 3; };
*
* and only store one pointer.
* I don't know if its possible but it may be possible to 'append' * the lambda's stack to the existing scope rather than creating a * new constrained scope -- from a logical point of view.
My motivation for investigating is that I consider constraining lambdas to be monomorphic significantly reduces their usefulness. I'm sure there are many good reasons why the committee decided that it was the way to go.
The following program generates the expected code and runs correctly.
auto f = [&] <typename T, typename U> (T n, T const& m, U u) { i = ++n; j = u(++n); k = ++n; };
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |