public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: 김륜현 <winxp4333@naver.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: C++ parameter pack compile error occurs in the capture block of the lambda from difference between gcc 4.8.2 and 4.9.4;
Date: Wed, 1 Sep 2021 10:50:53 +0100	[thread overview]
Message-ID: <CAH6eHdQP2cDyLXCQeY2kVLJPn2jS+GE05GbEfYXipWJTJ_zR4Q@mail.gmail.com> (raw)
In-Reply-To: <c516ecb732a2be837e1ddfbbb681bc40@cweb005.nm.nfra.io>

On Wed, 1 Sept 2021 at 04:51, 김륜현 via Gcc-help <gcc-help@gcc.gnu.org> wrote:
>
> Dear sir,
>
> Hi, I tried to compile my source code using gcc-linaro-aarch64-linux-gnu-4.8-2013.09-01_linux(gcc 4.8.2)
>
> The error occurred like below
>
> lamb.cpp:5:19: error: expected ‘,’ before ‘...’ token
>   auto zzz = [&args...](int ccc) -> int {
>                    ^
> lamb.cpp:5:19: error: expected identifier before ‘...’ token
> lamb.cpp:5:22: error: parameter packs not expanded with ‘...’:
>   auto zzz = [&args...](int ccc) -> int {
>                       ^
> lamb.cpp:5:22: note:         ‘args’
> lamb.cpp: In instantiation of ‘struct solve(const int&, Args&& ...) [with Args = {}]::__lambda0’:
> lamb.cpp:9:6:   required from ‘void solve(const int&, Args&& ...) [with Args = {}]’
> lamb.cpp:15:10:   required from here
> lamb.cpp:5:15: error: using invalid field ‘solve(const int&, Args&& ...)::__lambda0::__args’
>   auto zzz = [&args...](int ccc) -> int {
>                ^
>
> Here, I attach the code
>
> #include <stdio.h>
>
> template <typename... Args>
> void solve(const int &aa, Args &&... args) {
>         auto zzz = [&args...](int ccc) -> int {
>                 int res = 1;
>                 printf("%d",ccc);
>                 return res + ccc;
>         }(10);
>         printf("zzz : %d\n",zzz);
> }
>
> int main()
> {
>         solve(10);
> }
>
>
> Solve function syntax refer to the template parameter pack "Args" as r-value.
> And use "args" as a reference in the capture block of Lambda.
>
> Is It right? but, the compile error occurred.
>
> I think that this issue cause is that C++11 standard not implements this syntax in gcc 4.8 / implements in gcc 4.9
> Because I eventually changed the toolchain to gcc-linaro-4.9-2016.02-x86_64_aarch64-linux-gnu(gcc4.9.4) and Build was success.()
> And when i searched this issue in http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html, this issue was mentioned in No.904

See https://gcc.gnu.org/pipermail/gcc-help/2021-September/140667.html

> Is There workaround in gcc 4.8?(I want to change toolchain version. but, I should use gcc 4.8)

You could create a tuple from the parameter pack and capture the
tuple, but it will be awkward to access the elements. You should just
use a newer compiler if you want to compile C++11 code.

  reply	other threads:[~2021-09-01  9:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01  3:49 김륜현
2021-09-01  9:50 ` Jonathan Wakely [this message]
2021-09-01 10:22   ` 김륜현
2021-09-02  4:14     ` 김륜현
2021-09-02  6:26       ` Jonathan Wakely

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=CAH6eHdQP2cDyLXCQeY2kVLJPn2jS+GE05GbEfYXipWJTJ_zR4Q@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=winxp4333@naver.com \
    /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).