Change zend_ast_attr from uint16_t to uint32_t #20490
Open
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The zend_ast_attr type was defined as
uint16_t, limiting it to 16 bits, but it’s used to storeZEND_ACC_*flags which can use bits up to 31:While the current code doesn’t appear to assign these high-bit flags to
ast->attrfields, the type mismatch creates a potential bug where any future code attempting to store ZEND_ACC flags with bits 16–31 would have those bits silently truncated to zero.Additionally, several functions (
zend_ast_create_va,zend_ast_create_ex_*, etc.) acceptuint32_torzend_ast_attrparameters before assigning to the attr field, creating a truncation point at line 821 in zend_language_parser.y wherezend_modifier_list_to_flags()returnsuint32_t.This change:
zend_ast_kindtypedef fromuint16_ttouint32_tzend_ast_attrtypedef fromuint16_ttouint32_tExtending
kindtouint32_tmaintains natural alignment without requiring explicit padding fields. The structure sizes remain unchanged. Padding was already present implicitly due to alignment.