[Bug c++/87559] New: Storage duration + lambda captures: Discrepancy in behavior between g++-7 and clang++-6.0

eric.cousineau at tri dot global gcc-bugzilla@gcc.gnu.org
Mon Oct 8 22:03:00 GMT 2018


            Bug ID: 87559
           Summary: Storage duration + lambda captures: Discrepancy in
                    behavior between g++-7 and clang++-6.0
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.cousineau at tri dot global
  Target Milestone: ---

Created attachment 44812
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44812&action=edit
Reproduction + Output

- https://bugs.llvm.org/show_bug.cgi?id=39202
  - The cases posted here are *similar* to this clang bug report (comparing
against GCC 5), but there are some differences specific to this bug report.
- https://github.com/RobotLocomotion/drake/issues/9600

Attached is `output.txt`, which indicates compiler versions (GCC 7.3.0 vs.
clang 6.0.0), C++ code, and compiler output for a list of cases.

In each case, there is a defined variable, `top_doc`, and a local alias
variable, `doc`. Each case will vary the storage duration for both the defined
variable (and sometimes the local alias), and effectively checks the storage
duration by how the compiler treats the relevant lambda capture.

Observations and guesses from these results:

- Case 2.0: `constexpr auto&` alias to global + non-generic lambda. Works in
both gcc + clang.
- Case 2.1: `constexpr auto&` alias to global + generic lambda. Fails in GCC.
- Case 2.2: `constexpr` local + non-generic lambda. Fails in clang.
- Case 2.3: `constexpr` local + generic lambda. Fails in clang.

My main concern is the discrepancy between Case 2.0 and Case 2.1.
Since this is template/context-dependency dependent, it seems like a bug?

For Case 2.2 and 2.3, I'm once again not sure if GCC or clang is wrong in the
eyes of the standard.

More information about the Gcc-bugs mailing list