Repository navigation
Constant evaluation of GNU vector objects [GH #224] - #448
daveedvdv-nvidia wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Bitmap storage src/interpret.c |
A shared predicate includes GNU vectors among types that require tracked-subobject bitmap storage when GNU vector types are enabled. |
Whole-vector state tracking src/interpret.c |
Whole-subobject initialization and uninitialization now apply the existing bitmap tracking path to vectors. |
Regression coverage tests/tests/regressions/gh-224.sft.cpp, tests/tests/regressions/gh-224-diag.sft.cpp, tests/tests/regressions/.gh-224*.rto/*, src/pending_changes/gh-224-constexpr-vector-init-bitmap.txt |
Tests cover constexpr vector initialization and expected uninitialized-object diagnostics after destruction. The regression fixtures and GH #224 report are added. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested labels: bug
Suggested reviewers: nv-cmeerw
Merge Risk: 
Minimal · up to 3c40d
-
No merge-blocking issue was identified. Run the regression tests through normal checks.
Pre-merge checks: 
4
-
Full details: Linked Issues check
-
Explanation
Issue
#224requires fixing GNU vector initialization tracking that can write outside the allocation.has_tracked_subobjectsincludestk_vector, andcompute_prefix_size_for_typetherefore reserves the bitmap for complete vector objects. The same predicate makes whole-vector initialization and destruction update all element states. The addedgh-224.sft.cppand diagnostic regression tests cover 64-byte vectors, vector subobjects, whole-vector assignment, and post-destruction element reads.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within Issue
#224. The source change updates only initialization bitmap allocation and whole-subobject tracking for classes, arrays, and GNU vectors. The pending-change report and regression tests document and verify the reported vector failures. No unrelated behavior is changed.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
dkolsen-pgi
left a comment
There was a problem hiding this comment.
Looks good.
Good job finding the bug of not marking the whole object as initialized or uninitialized. I ran across that while debugging the problem, but didn't realize that it was incorrect.
Fixes #224.
The constexpr interpreter tracks the initialization of each element of a GNU vector in the initialization bitmap of the enclosing complete object (e.g.,
init_subobject_to_zeromarks every element). However,compute_prefix_size_for_typereserved a bitmap only for class and array types, so for a complete object of vector type those bits landed in the alignment padding of the bookkeeping prefix and, for larger vectors (64 bytes suffices), before the start of the allocation. That's the out-of-bounds access ASan reports for the example in the issue.A related problem:
mark_whole_subobject_initializedandmark_whole_subobject_uninitializedtreated a vector like a scalar and updated only the bit of its first element. So assigning a whole vector subobject and then reading a later element gave a spurious "access to uninitialized object" error (GCC and Clang accept it):and reading an element of a vector member after destroying it (
s.v.~vl8(); return s.v[7];) was not diagnosed (Clang rejects it).This change adds a
has_tracked_subobjectspredicate (class, array, or vector type) and uses it in those three places.Summary by CodeRabbit