https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108407

            Bug ID: 108407
           Summary: SegFault with structured binding and OpenMP without
                    optimization
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mmoelle1 at gmail dot com
  Target Milestone: ---

The following code snippet compiles well but the binary stops with a
segmentation fault when compiled with 'g++ -O0  -std=c++17'. When compiled with
optimization (-O1 or better) turned on the binary works fine.

#include <tuple>
#ifdef OPENMMP_
#include <omp.h>
#endif

auto create()
{
  int    a = 10;
  double b = 1.0;
  return std::tie(a,b);
}

int main()
{
  auto [a, b] = create();
  double vector[100];

#pragma omp parallel for
  for (int i=0; i<a; ++i)
    vector[i] = b;
}

Reply via email to