• Robert Edmonds's avatar
    protoc-c: c_message: Add extra braces to initialize a oneof union containing a ProtobufCBinaryData · cecf01e6
    Robert Edmonds authored
    Certain compilers (e.g. [0]) incorrectly generate warning messages
    when the universal zero initializer is used by the protobuf-c generated
    code to initialize a protobuf object containing a oneof that contains a
    ProtobufCBinaryData field as the first member. This is now much more
    likely due to the change in the previous commit ("protoc-c: c_message:
    Order oneof union members from largest to smallest") which will now
    always cause a ProtobufCBinaryData field to be placed as the first
    member of the union, if one is present in the oneof.
    
    In this situation, we need to add an extraneous pair of braces around
    the universal zero initializer in the generated initialization code.
    
    The former behavior of using the universal zero initializer by itself is
    kept for oneof unions that do not contain a ProtobufCBinaryData member.
    
    [0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80454
    cecf01e6
c_message.cc 25.1 KB