Skip to content

[pulse] do not report uninitialized members of modelled field references - #2312

Open
VladimirMakaev wants to merge 1 commit into
meta:mainfrom
VladimirMakaev:pulse-thrift-field-ref-uninit
Open

VladimirMakaev wants to merge 1 commit into
meta:mainfrom
VladimirMakaev:pulse-thrift-field-ref-uninit

Conversation

@VladimirMakaev

Copy link
Copy Markdown
Contributor

Pulse models the constructors of the field-reference classes listed in Typ.thrift_field_refs
by storing the referenced field only. The other members of the object, such as an is set bit
reference with a default member initializer, stay uninitialized, so the accessors that are not
modelled (has_value(), value_or(), ...) read uninitialized values when their bodies are
translated. These classes are now in the uninitialized-value blocklist, like std::optional.

struct S {
  int value{0};
  unsigned char isset{0};
  optional_field_ref<int&> field() { return {value, isset}; }
};
bool f(S& s) { return s.field().has_value(); } // reported: `this.bit_.is_atomic_` uninitialized

Test plan

New has_value_ok in cpp/pulse/thrift_field_ref.cpp, with a field reference whose is set bit
reference has a default member initializer. The cpp/pulse and cpp/pulse-11 cases pass.

@meta-cla meta-cla Bot added the CLA Signed label Nov 20, 2026
Pulse models the constructors of the field-reference classes listed in `Typ.thrift_field_refs`
by storing the referenced field only. The other members of the object, such as an `is set` bit
reference with a default member initializer, stay uninitialized, so the accessors that are not
modelled (`has_value()`, `value_or()`, ...) read uninitialized values when their bodies are
translated. These classes are now in the uninitialized-value blocklist, like `std::optional`.

```cpp
struct S {
  int value{0};
  unsigned char isset{0};
  optional_field_ref<int&> field() { return {value, isset}; }
};
bool f(S& s) { return s.field().has_value(); } // reported: `this.bit_.is_atomic_` uninitialized
```

## Test plan
New `has_value_ok` in `cpp/pulse/thrift_field_ref.cpp`, with a field reference whose `is set` bit
reference has a default member initializer. The cpp/pulse and cpp/pulse-11 cases pass.
@VladimirMakaev
VladimirMakaev force-pushed the pulse-thrift-field-ref-uninit branch from 8808822 to 19566be Compare November 20, 2026 16:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant