view gcc/testsuite/g++.dg/cpp0x/pr83160.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
line wrap: on
line source

// { dg-do run { target c++11 } }
// PR c++/83160 failed to capture as lvalue

int main ()
{
  const int a = 0;

  if (![&a] (const int *p)
      {
	const int &b = a;
	// We should bind to the outer a
	return &b == p;
      } (&a))
    return 1;

  if (![&] (const int *p)
      {
	const int &b = a;
	// We should bind to the outer a
	return &b == p;
      } (&a))
    return 2;

  if ([=] (const int *p)
      {
	const int &b = a;
	// We should bind to the captured instance
	return &b == p;
      }(&a))
    return 3;

  return 0;
}