FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/cpp/ql/test/library-tests/padding/cpp.cpp at codeql-cli-2.11.3 · github/codeql · GitHub
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Issues
1k
Pull requests
470
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
cpp
/
ql
/
test
/
library-tests
/
padding
/
cpp.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
278 lines (244 loc) · 5.5 KB
Breadcrumbs
codeql
/
cpp
/
ql
/
test
/
library-tests
/
padding
/
cpp.cpp
Copy path
File metadata and controls
278 lines (244 loc) · 5.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#
include
"
size_asserts.h
"
CASSERT_MSVC
(
sizeof
(
wchar_t
) ==
2
);
CASSERT_GCC
(
sizeof
(
wchar_t
) ==
4
);
struct
ReferencesAndPointers
{
//
0
char
c1;
//
1
//
Pad 7(GCC64, MSVC64); 3(GCC32, MSVC32)
//
8(GCC64, MSVC64); 4(GCC32, MSVC32)
short
& r2;
//
16(GCC64, MSVC64); 8(GCC32, MSVC32)
wchar_t
wc3;
//
18(GCC64, MSVC64); 10(GCC32, MSVC32)
//
Pad 6(GCC64, MSVC64); 2(GCC32, MSVC32)
//
24(GCC64, MSVC64); 12(GCC32, MSVC32)
long
long
* p4;
//
32(GCC64, MSVC64); 16(GCC32, MSVC32)
};
CASSERT_MSVC64
(
sizeof
(
struct
ReferencesAndPointers
) ==
32
);
CASSERT_MSVC32
(
sizeof
(
struct
ReferencesAndPointers
) ==
16
);
CASSERT_GCC64
(
sizeof
(
struct
ReferencesAndPointers
) ==
32
);
CASSERT_GCC32
(
sizeof
(
struct
ReferencesAndPointers
) ==
16
);
enum
E {
E_None
};
CASSERT
(
sizeof
(E) ==
sizeof
(
int
));
enum
E_char :
char
{
E_char_None
};
CASSERT
(
sizeof
(E_char) ==
sizeof
(
char
));
enum
E_short :
short
{
E_short_None
};
CASSERT
(
sizeof
(E_short) ==
sizeof
(
short
));
enum
E_int :
int
{
E_int_None
};
CASSERT
(
sizeof
(E_int) ==
sizeof
(
int
));
enum
E_long :
long
{
E_long_None
};
CASSERT
(
sizeof
(E_long) ==
sizeof
(
long
));
enum
E_longlong :
long
long
{
E_longlong_None
};
CASSERT
(
sizeof
(E_longlong) ==
sizeof
(
long
long
));
enum
class
EC
{
None
};
CASSERT
(
sizeof
(
EC
) ==
sizeof
(
int
));
enum
class
EC_char
:
char
{
None
};
CASSERT
(
sizeof
(EC_char) ==
sizeof
(
char
));
enum
class
EC_short
:
short
{
None
};
CASSERT
(
sizeof
(EC_short) ==
sizeof
(
short
));
enum
class
EC_int
:
int
{
None
};
CASSERT
(
sizeof
(EC_int) ==
sizeof
(
int
));
enum
class
EC_long
:
long
{
None
};
CASSERT
(
sizeof
(EC_long) ==
sizeof
(
long
));
enum
class
EC_longlong
:
long
long
{
None
};
CASSERT
(
sizeof
(EC_longlong) ==
sizeof
(
long
long
));
struct
Enums_Packed
{
//
0
E_longlong ell;
//
8
E_long el;
//
16(GCC64); 12(GCC32, MSVC)
E_int ei;
//
20(GCC64); 16(GCC32, MSVC)
E e;
//
24(GCC64); 20(GCC32, MSVC)
E_short es;
//
26(GCC64); 22(GCC32, MSVC)
E_char ec;
//
27(GCC64); 23(GCC32, MSVC)
//
Pad 5(GCC64); 1(GCC32, MSVC)
//
32(GCC64); 24(GCC32, MSVC)
};
CASSERT_GCC64
(
sizeof
(Enums_Packed) ==
32
);
CASSERT_GCC32
(
sizeof
(Enums_Packed) ==
24
);
CASSERT_MSVC
(
sizeof
(Enums_Packed) ==
24
);
struct
Enums_MixedBitfields
{
//
0
E_short ei1 :
8
;
//
1
short
s2 :
8
;
//
2
};
CASSERT_GCC
(
sizeof
(Enums_MixedBitfields) ==
2
);
CASSERT_MSVC
(
sizeof
(Enums_MixedBitfields) ==
2
);
struct
Enums_MixedBitfields_Padded
{
//
0
E_short ei1 :
8
;
//
1
//
Pad 1(MSVC); 0(GCC)
//
2(MSVC); 1(GCC)
unsigned
char
uc2 :
8
;
//
3(MSVC); 2(GCC)
//
Pad 1(MSVC); 0(GCC)
//
4(MSVC); 2(GCC)
};
CASSERT_GCC
(
sizeof
(Enums_MixedBitfields_Padded) ==
2
);
CASSERT_MSVC
(
sizeof
(Enums_MixedBitfields_Padded) ==
4
);
struct
Base_Empty
{
//
0
//
Pad 1
//
1
};
CASSERT
(
sizeof
(Base_Empty) ==
1
);
struct
Derived_EmptyBase
: Base_Empty {
//
0
//
Base class Base_Empty (Empty Base Optimization)
//
0
int
n1;
//
4
};
CASSERT
(
sizeof
(Derived_EmptyBase) ==
4
);
struct
Base_NoPadding
{
//
0
int
n1;
//
4
};
CASSERT
(
sizeof
(Base_NoPadding) ==
4
);
struct
Derived_NoBasePadding
: Base_NoPadding {
//
0
//
Base class Base_NoPadding
//
4
int
n2;
//
8
};
CASSERT
(
sizeof
(Derived_NoBasePadding) ==
8
);
struct
Base_Padding
{
//
0
float
f1;
//
4
short
s1;
//
6
//
Pad 2
//
8
};
CASSERT
(
sizeof
(Base_Padding) ==
8
);
struct
Derived_BasePadding
: Base_Padding {
//
0
//
Base class Base_Padding
//
8
short
s2;
//
10
//
Pad 2
//
12
};
CASSERT
(
sizeof
(Derived_BasePadding) ==
12
);
struct
Intermediate_NoFields
: Base_NoPadding {
//
0
//
Base class Base_NoPadding
//
4
};
CASSERT
(
sizeof
(Intermediate_NoFields) ==
4
);
struct
Derived_NonEmptyBaseWithNoFields
: Intermediate_NoFields {
//
0
//
Base class Intermediate_NoFields
//
4
int
n2;
//
8
};
CASSERT
(
sizeof
(Derived_NonEmptyBaseWithNoFields) ==
8
);
struct
MultipleInheritance
: Base_NoPadding, Base_Padding {
int
n3;
};
CASSERT
(
sizeof
(MultipleInheritance) ==
16
);
struct
StaticMemberVariables
{
//
0
static
int
s_n1;
//
0
float
f1;
//
4
static
int
s_n2;
//
4
};
CASSERT
(
sizeof
(StaticMemberVariables) ==
4
);
struct
VirtualInheritance
:
virtual
Base_NoPadding {
int
n3;
};
struct
Derived_EmptyBase_Conflict1
: Base_Empty {
//
0
//
Base class Base_Empty (GCC Only: no Empty Base Optimization due to conflict with m1)
//
1(GCC); 0(MSVC)
Base_Empty m1;
//
2(GCC); 1(MSVC)
};
CASSERT_GCC
(
sizeof
(Derived_EmptyBase_Conflict1) ==
2
);
CASSERT_MSVC
(
sizeof
(Derived_EmptyBase_Conflict1) ==
1
);
struct
Derived_EmptyBase_Conflict2
: Base_Empty {
//
0
//
Base class Base_Empty (GCC Only: no Empty Base Optimization due to conflict with m1)
//
1(GCC); 0(MSVC)
//
Pad 3(GCC); 0(MSVC)
//
4(GCC); 0(MSVC)
Derived_EmptyBase m1;
//
8(GCC); 4(MSVC)
};
CASSERT_GCC
(
sizeof
(Derived_EmptyBase_Conflict2) ==
8
);
CASSERT_MSVC
(
sizeof
(Derived_EmptyBase_Conflict2) ==
4
);
struct
Base_Empty2
: Base_Empty {
//
0
//
Base class Base_Empty (Empty Base Optimization)
//
0
//
Pad 1
//
1
};
CASSERT
(
sizeof
(Base_Empty2) ==
1
);
struct
Derived_EmptyBase_Conflict3
: Base_Empty2 {
//
0
//
Base class Base_Empty2 (GCC Only: no Empty Base Optimization due to conflict with m1)
//
1(GCC); 0(MSVC)
Base_Empty m1;
//
2(GCC); 1(MSVC)
};
CASSERT_GCC
(
sizeof
(Derived_EmptyBase_Conflict3) ==
2
);
CASSERT_MSVC
(
sizeof
(Derived_EmptyBase_Conflict3) ==
1
);
struct
Base_NoPaddingButSmallAlignment
{
//
0
short
s1;
//
2
};
CASSERT
(
sizeof
(Base_NoPaddingButSmallAlignment) ==
2
);
struct
Derived_NoBasePaddingButNeedsAlignmentPadding
: Base_NoPaddingButSmallAlignment {
//
0
//
Base class Base_NoPaddingButSmallAlignment
//
2
//
Pad 2
//
4
int
n1;
//
8
};
CASSERT
(
sizeof
(Derived_NoBasePaddingButNeedsAlignmentPadding) ==
8
);
Back
|
FazBrowse Home
|
New Git URL