[Bug c++/105491] Usage of __constinit with -std=c++11 does is rejected

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 5 14:38:43 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105491

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Reduced.  Works with -std=c++17 but not 14.  It's about the union in
ProtobufCFileOptionsDefaultTypeInternal.


class Message {
  virtual int GetMetadata();
};
class ProtobufCFileOptions : Message {
public:
  constexpr ProtobufCFileOptions(int);
  bool no_generate_;
  bool const_strings_;
  bool use_oneof_field_name_;
  bool gen_pack_helpers_;
  bool gen_init_helpers_;
};
constexpr ProtobufCFileOptions::ProtobufCFileOptions(int)
    : no_generate_(), const_strings_(), use_oneof_field_name_(),
      gen_pack_helpers_(), gen_init_helpers_() {}
struct ProtobufCFileOptionsDefaultTypeInternal {
  constexpr ProtobufCFileOptionsDefaultTypeInternal() : _instance({}) {}
  union {
    ProtobufCFileOptions _instance;
  };
} __constinit _ProtobufCFileOptions_default_instance_;


More information about the Gcc-bugs mailing list