public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61814] New: [c++1y] cannot use decltype on captured arg-pack
@ 2014-07-15 15:44 tongari95 at gmail dot com
2014-10-23 12:23 ` [Bug c++/61814] " oakad at yahoo dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: tongari95 at gmail dot com @ 2014-07-15 15:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61814
Bug ID: 61814
Summary: [c++1y] cannot use decltype on captured arg-pack
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tongari95 at gmail dot com
The code below has a lambda that captures the outer params t, for forwarding
matter, decltype on t has to be used.
```
auto const pack = [](auto&&... t)
{
return [&](auto&& f)->decltype(auto)
{
return f(static_cast<decltype(t)>(t)...);
};
};
int main(int argc, char** argv) {
pack(1)([](int){});
return 0;
}
```
It works with clang 3.5, but g++ 4.9.0 complains:
error: 't' was not declared in this scope
The same also applies to `sizeof` or that kind of compile-time thing.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/61814] [c++1y] cannot use decltype on captured arg-pack
2014-07-15 15:44 [Bug c++/61814] New: [c++1y] cannot use decltype on captured arg-pack tongari95 at gmail dot com
@ 2014-10-23 12:23 ` oakad at yahoo dot com
2014-10-23 12:29 ` redi at gcc dot gnu.org
2014-10-23 12:39 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: oakad at yahoo dot com @ 2014-10-23 12:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61814
Alexander Dubov <oakad at yahoo dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |oakad at yahoo dot com
--- Comment #1 from Alexander Dubov <oakad at yahoo dot com> ---
This problem still happens on 4.9.1.
For example, this example works:
int main(int argc, char **argv)
{
int a{5};
float z(0.5);
[&a](float z_) -> void {
decltype(a) b = a;
}(z);
return 0;
}
But this basic modification fails to compile (g++-4.9.1 -std=gnu++14):
int main(int argc, char **argv)
{
int a{5};
float z(0.5);
[&a](auto z_) -> void {
decltype(a) b = a;
}(z);
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/61814] [c++1y] cannot use decltype on captured arg-pack
2014-07-15 15:44 [Bug c++/61814] New: [c++1y] cannot use decltype on captured arg-pack tongari95 at gmail dot com
2014-10-23 12:23 ` [Bug c++/61814] " oakad at yahoo dot com
@ 2014-10-23 12:29 ` redi at gcc dot gnu.org
2014-10-23 12:39 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-23 12:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61814
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Alexander Dubov from comment #1)
> But this basic modification fails to compile (g++-4.9.1 -std=gnu++14):
>
> int main(int argc, char **argv)
> {
> int a{5};
> float z(0.5);
> [&a](auto z_) -> void {
> decltype(a) b = a;
> }(z);
> return 0;
> }
That seems to be a different issue, and is fixed on trunk.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/61814] [c++1y] cannot use decltype on captured arg-pack
2014-07-15 15:44 [Bug c++/61814] New: [c++1y] cannot use decltype on captured arg-pack tongari95 at gmail dot com
2014-10-23 12:23 ` [Bug c++/61814] " oakad at yahoo dot com
2014-10-23 12:29 ` redi at gcc dot gnu.org
@ 2014-10-23 12:39 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-23 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61814
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-10-23
CC| |jason at gcc dot gnu.org
Known to work| |5.0
Ever confirmed|0 |1
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Actually the original problem is fixed on trunk too (but gives a different
error now), so maybe it is the same and can be reduced to:
int main()
{
int a{5};
[&a](auto z) -> void {
decltype(a) b = a;
}(1);
}
l.cc: In instantiation of ‘main()::<lambda(auto:1)> [with auto:1 = int]’:
l.cc:6:6: required from here
l.cc:5:17: error: ‘a’ was not declared in this scope
decltype(a) b = a;
^
The error goes away if the lambda doesn't have a trailing-return-type, or if
it's not a generic lambda.
Jason, is it worth fixing this on the branch? It only affects C++14 mode.
>From gcc-bugs-return-464737-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Oct 23 12:39:35 2014
Return-Path: <gcc-bugs-return-464737-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31741 invoked by alias); 23 Oct 2014 12:39:35 -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 31654 invoked by uid 48); 23 Oct 2014 12:39:31 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63628] New: [c++1y] cannot use decltype on captured variable in generic lambda
Date: Thu, 23 Oct 2014 12:41: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: 5.0
X-Bugzilla-Keywords: rejects-valid
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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc blocked
Message-ID: <bug-63628-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-10/txt/msg01758.txt.bz2
Content-length: 1264
https://gcc.gnu.org/bugzilla/show_bug.cgi?idc628
Bug ID: 63628
Summary: [c++1y] cannot use decltype on captured variable in
generic lambda
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: daniel.kruegler at googlemail dot com, jason at gcc dot gnu.org,
oakad at yahoo dot com, tongari95 at gmail dot com
Blocks: 54367
+++ This bug was initially created as a clone of Bug #61814 +++
The code below has a lambda that captures the outer params t, for forwarding
matter, decltype on t has to be used.
```
auto const pack = [](auto&&... t)
{
return [&](auto&& f)->decltype(auto)
{
return f(static_cast<decltype(t)>(t)...);
};
};
int main(int argc, char** argv) {
pack(1)([](int){});
return 0;
}
```
It works with clang 3.5, but g++ 4.9.0 complains:
error: 't' was not declared in this scope
The same also applies to `sizeof` or that kind of compile-time thing.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-23 12:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15 15:44 [Bug c++/61814] New: [c++1y] cannot use decltype on captured arg-pack tongari95 at gmail dot com
2014-10-23 12:23 ` [Bug c++/61814] " oakad at yahoo dot com
2014-10-23 12:29 ` redi at gcc dot gnu.org
2014-10-23 12:39 ` 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).