Skip to content

Conversation

@Databean
Copy link
Member

The standard says that accessing unaligned values by reference is undefined behavior. These overloads of cuttlefish::Pretty capture calls that use numeric values and pass them by value rather than the default pass-by-reference fallback defined in pretty.h. This is because numeric values are likely to appear in __attribute__((packed)) structs which can have unaligned values.

#2014 introduced pretty-printing for some packed structs which have unaligned fields and it ran into this issue trying to pass the struct fields by reference, so it was reverted in #2025 .

Bug: b/476228593

The standard says that accessing unaligned values by reference is
undefined behavior. These overloads of `cuttlefish::Pretty` capture
calls that use numeric values and pass them by value rather than the
default pass-by-reference fallback defined in `pretty.h`. This is
because numeric values are likely to appear in `__attribute__((packed))`
structs which can have unaligned values.

google#2014 introduced
pretty-printing for some packed structs which have unaligned fields and
it ran into this issue trying to pass the struct fields by reference, so
it was reverted in google#2025 .

Bug: b/476228593
@Databean Databean requested a review from ser-io January 20, 2026 19:35
@Databean Databean added this pull request to the merge queue Jan 21, 2026
@Databean
Copy link
Member Author

Thanks for reviewing!

@Databean Databean changed the title Add numeric overloads for cuttlefish::Preetty. Add numeric overloads for cuttlefish::Pretty. Jan 21, 2026
Merged via the queue into google:main with commit 828ce4b Jan 22, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants