This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Use value initializer for OVERLAPPED
ClosedPublic

Authored by aeubanks on Aug 6 2020, 3:36 PM.

Details

Summary

To fix
../llvm/lib/Support/Windows/Path.inc(1265,21): warning: missing field
'InternalHigh' initializer [-Wmissing-field-initializers]

OVERLAPPED OV = {0};

Diff Detail

Event Timeline

aeubanks created this revision.Aug 6 2020, 3:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2020, 3:36 PM
aeubanks requested review of this revision.Aug 6 2020, 3:36 PM
hans accepted this revision.Aug 7 2020, 10:58 AM

lgtm, looks like we already do this elsewhere in the file.

This revision is now accepted and ready to land.Aug 7 2020, 10:58 AM
This revision was landed with ongoing or failed builds.Aug 7 2020, 11:18 AM
This revision was automatically updated to reflect the committed changes.

Huh, I thought aggregate initialization was effectively zero-initialization for the remaining fields, so I'm surprised this changes anything. I would have expected the original line, which is idiomatic in Win32 code, to have zero-initialized all of the fields.

But it looks like the field in question is part of a union, so maybe the rules there are different. I'll read up on it, but I don't see any harm here.

OK, I see. I was looking at the wrong field.

I'm not sure I see the value in this warning. I'd argue the replacement code is less clear. It's contrary to the entrenched idiom for Win32 programming. The old code in valid and correct in both C and C++, but the new code is not allowed in C.

"In C, the braced list of initializers cannot be empty (note that C++ allows empty lists ...)." https://en.cppreference.com/w/c/language/struct_initialization