Skip to content

Commit

Permalink
Avoid a 'may be used uninitialized' warning when built with '-c opt'. (
Browse files Browse the repository at this point in the history
…#15846)

The motivation for this is first that under some combinations of flags it breaks builds and second it's trivial (and possibly zero runtime cost) to fix.

It looks like the possibly bad case "should never happen", but converting this to a null pointer in the error case (which should at least make the failure less problematic) is cheap.

Closes #15846

COPYBARA_INTEGRATE_REVIEW=#15846 from bcsgh:bcsgh/uninitialized 321d649
PiperOrigin-RevId: 607404168
  • Loading branch information
bcsgh authored and Copybara-Service committed Feb 15, 2024
1 parent a938b59 commit eb70b34
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/google/protobuf/arena.cc
Expand Up @@ -193,7 +193,7 @@ SizedPtr SerialArena::Free(Deallocator deallocator) {
PROTOBUF_NOINLINE
void* SerialArena::AllocateAlignedFallback(size_t n) {
AllocateNewBlock(n);
void* ret;
void* ret = nullptr;
bool res = MaybeAllocateAligned(n, &ret);
ABSL_DCHECK(res);
return ret;
Expand Down

0 comments on commit eb70b34

Please sign in to comment.