52 lines · cpp
1// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s2 3struct A {4 union {5 int n = 0;6 int m;7 };8};9const A a;10 11struct B {12 union {13 struct {14 int n = 5;15 int m;16 };17 };18};19const B b; // expected-error {{default initialization of an object of const type 'const B' without a user-provided default constructor}}20 21struct S {22 int i;23 int j;24};25 26struct T {27 T() = default;28};29 30struct C {31 union {32 S s;33 };34};35 36struct D {37 union {38 T s;39 };40};41 42const C c; // expected-error {{default initialization of an object of const type 'const C' without a user-provided default constructor}}43const D d; // expected-error {{default initialization of an object of const type 'const D' without a user-provided default constructor}}44 45struct E {46 union {47 int n;48 int m=0;49 };50};51const E e;52