File tree Expand file tree Collapse file tree 4 files changed +22
-16
lines changed Expand file tree Collapse file tree 4 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,10 @@ BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4275));
9797// /
9898class exception : public std ::system_error {
9999 public:
100- ~exception () override ;
101-
102- exception (exception&&) noexcept = default ;
103- exception& operator =(exception&&) noexcept = default ;
104- exception (exception const &) = default ;
105- exception& operator =(exception const &) = default ;
106-
107100 using std::system_error::system_error;
101+
102+ private:
103+ BSONCXX_ABI_NO_EXPORT virtual void key_function () const ;
108104};
109105
110106BSONCXX_PRIVATE_WARNINGS_POP ();
Original file line number Diff line number Diff line change @@ -85,7 +85,14 @@ std::error_category const& type_error_category() {
8585namespace bsoncxx {
8686namespace v1 {
8787
88- exception::~exception () = default ;
88+ // Prevent vague linkage of the vtable and type_info object (-Wweak-vtables).
89+ // - https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable
90+ // > The key function is the first non-pure virtual function that is not inline at the point of class definition.
91+ // - https://lld.llvm.org/missingkeyfunction:
92+ // > It’s always advisable to ensure there is at least one eligible function that can serve as the key function.
93+ // - https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html
94+ // > For polymorphic classes (classes with virtual functions), the ‘type_info’ object is written out along with the vtable.
95+ void exception::key_function () const {}
8996
9097} // namespace v1
9198} // namespace bsoncxx
Original file line number Diff line number Diff line change @@ -100,14 +100,10 @@ BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4275));
100100// /
101101class exception : public std ::system_error {
102102 public:
103- ~exception () override ;
104-
105- exception (exception&&) noexcept = default ;
106- exception& operator =(exception&&) noexcept = default ;
107- exception (exception const &) = default ;
108- exception& operator =(exception const &) = default ;
109-
110103 using std::system_error::system_error;
104+
105+ private:
106+ MONGOCXX_ABI_NO_EXPORT virtual void key_function () const ;
111107};
112108
113109BSONCXX_PRIVATE_WARNINGS_POP ();
Original file line number Diff line number Diff line change @@ -83,7 +83,14 @@ std::error_category const& type_error_category() {
8383 return instance.value ();
8484}
8585
86- exception::~exception () = default ;
86+ // Prevent vague linkage of the vtable and type_info object (-Wweak-vtables).
87+ // - https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable
88+ // > The key function is the first non-pure virtual function that is not inline at the point of class definition.
89+ // - https://lld.llvm.org/missingkeyfunction:
90+ // > It’s always advisable to ensure there is at least one eligible function that can serve as the key function.
91+ // - https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html
92+ // > For polymorphic classes (classes with virtual functions), the ‘type_info’ object is written out along with the vtable.
93+ void exception::key_function () const {}
8794
8895} // namespace v1
8996} // namespace mongocxx
You can’t perform that action at this time.
0 commit comments