forked from theuni/bitcoin-tidy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_desig_init.cpp
35 lines (30 loc) · 828 Bytes
/
test_desig_init.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http:https://www.opensource.org/licenses/mit-license.php.
struct HasDefault
{
int val{0};
};
struct HasNoDefault
{
int val;
};
struct A {
struct Options {
HasDefault defval;
HasNoDefault nodefval;
unsigned cache_size;
signed delta;
bool in_memory = false;
};
A(const Options&) {} // unsafe (may have fields uninitialized)
A(unsigned cache_size, signed delta, bool in_memory = false) {} // safe, all non-default args are initialized
};
// Test should warn that A::Options::cache_size and A::Options::HasNoDefault::val are uninitialized.
int main() {
(void)A{
A::Options{
.delta = -1,
},
};
}