Skip to content

Commit 51d83d5

Browse files
vtjnashpull[bot]
authored andcommitted
ensure sub-bitfield bits are always defined (JuliaLang#49471)
Helps avoid UB or inconsistencies between Julia and C definitions.
1 parent 6e8e50e commit 51d83d5

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/datatype.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jl_datatype_t *jl_new_uninitialized_datatype(void)
106106
t->maybe_subtype_of_cache = 1;
107107
t->ismutationfree = 0;
108108
t->isidentityfree = 0;
109+
t->padding = 0;
109110
t->name = NULL;
110111
t->super = NULL;
111112
t->parameters = NULL;

src/julia.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ typedef struct _jl_value_t jl_value_t;
9292
struct _jl_taggedvalue_bits {
9393
uintptr_t gc:2;
9494
uintptr_t in_image:1;
95+
#ifdef _P64
96+
uintptr_t padding:61;
97+
#else
98+
uintptr_t padding:29;
99+
#endif
95100
};
96101

97102
JL_EXTENSION struct _jl_taggedvalue_t {
@@ -555,6 +560,7 @@ typedef struct _jl_datatype_t {
555560
uint16_t isprimitivetype:1; // whether this is declared with 'primitive type' keyword (sized, no fields, and immutable)
556561
uint16_t ismutationfree:1; // whether any mutable memory is reachable through this type (in the type or via fields)
557562
uint16_t isidentityfree:1; // whether this type or any object reachable through its fields has non-content-based identity
563+
uint16_t padding:6;
558564
} jl_datatype_t;
559565

560566
typedef struct _jl_vararg_t {
@@ -579,6 +585,7 @@ typedef struct _jl_binding_t {
579585
uint8_t imported:1;
580586
uint8_t usingfailed:1;
581587
uint8_t deprecated:2; // 0=not deprecated, 1=renamed, 2=moved to another package
588+
uint8_t padding:2;
582589
} jl_binding_t;
583590

584591
typedef struct {

src/module.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ static jl_binding_t *new_binding(jl_module_t *mod, jl_sym_t *name)
182182
b->imported = 0;
183183
b->deprecated = 0;
184184
b->usingfailed = 0;
185+
b->padding = 0;
185186
JL_GC_PUSH1(&b);
186187
b->globalref = jl_new_globalref(mod, name, b);
187188
JL_GC_POP();

0 commit comments

Comments
 (0)