aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/paren-init10.C
blob: 8e635de4514bf11ed7b8cd50a259afbb9a8925d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// PR c++/91363 - P0960R3: Parenthesized initialization of aggregates.
// { dg-do compile { target c++20 } }

// Test from [dcl.init].

struct A {
  int a;
  int&& r;
};

int f();
int n = 10;

A a1{1, f()};               // OK, lifetime is extended
A a2(1, f());               // well-formed, but dangling reference
A a3{1.0, 1};               // { dg-error "narrowing conversion" }
A a4(1.0, 1);               // well-formed, but dangling reference
A a5(1.0, static_cast<int&&>(n));    // OK