gcc 5 fails at valid lambda code

Bug #1709234 reported by Alexander Rabtchevich
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linux Mint
New
Undecided
Unassigned

Bug Description

Hello
The bug was found at an attempt of compilation of the mater branch of darktable from git. Roman Lebedev, the author of the code, asked to file a bug in OS bugtracker.

Linux Mint 18.2 Mate x64.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

Here is the duplicate of the bug, filled by him in debian bugtracker https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=871250

Package: g++-5
Version: 5.4.1-11
Severity: normal
Tags: upstream

The test-case is creduced.
Only the GCC5 fails, gcc-4.9, 6 and 7 do not.
clang-3.9, 4, 5, trunk is also fine with that code.

$ g++-7 -std=c++14 -c main.cpp
$ g++-6 -std=c++14 -c main.cpp
$ g++-5 -std=c++14 -c main.cpp

main.cpp: In instantiation of ‘d::n() const::<lambda(auto:1, d::h, d::h,
int, d::n() const::p, d::n() const::p)> [with auto:1 = d::n()
const::<lambda()>]’:
main.cpp:26:28: required from here
main.cpp:23:11: error: ‘e’ is not captured
     if (e < e)
                ^
main.cpp:23:11: note: ‘const int& e’ declared here

- -- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'unstable-debug'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.11.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages g++-5 depends on:
ii gcc-5 5.4.1-11
ii gcc-5-base 5.4.1-11
ii libc6 2.24-14
ii libgmp10 2:6.1.2+dfsg-1
ii libisl15 0.18-1
ii libmpc3 1.0.3-1+b2
ii libmpfr4 3.1.5-1
ii libstdc++-5-dev 5.4.1-11
ii zlib1g 1:1.2.8.dfsg-5

g++-5 recommends no packages.

Versions of packages g++-5 suggests:
pn g++-5-multilib <none>
pn gcc-5-doc <none>
pn libstdc++6-5-dbg <none>

- -- no debconf information

*** /home/lebedevri/CREDUCE/main.cpp
using a = int;
using c = int;
struct d {
  struct {
    a e;
  } f;
  enum h { i, j };
  struct k {
    int l[0][0];
  };
  int m(k *, c *, a, int, int *) const;
  void n() const;
};
void d::n() const {
  c *o;
  k *info;
  struct p {
  } g;
  p b;
  int errcnt;
  const int e = f.e;
  auto pass = [&](auto, h, h, int, p, p) {
    if (e < e)
      errcnt = m(0, o, 0, 0, info->l[0]);
  };
  pass([] {}, i, j, 0, g, b);
}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.