westonpace commented on code in PR #33847:
URL: https://github.com/apache/arrow/pull/33847#discussion_r1087020212
##########
cpp/src/arrow/type.h:
##########
@@ -288,31 +288,46 @@ std::shared_ptr<DataType> GetPhysicalType(const
std::shared_ptr<DataType>& type)
class ARROW_EXPORT FixedWidthType : public DataType {
public:
using DataType::DataType;
+ // This is only for preventing defining this class in each
+ // translation unit to avoid one-definition-rule violation.
+ ~FixedWidthType() override;
Review Comment:
I understand why adding that destructor changes W to U. You are defining a
non-inline key function. Therefore the vtable is defined in only one place.
However, I don't understand why it is an ODR error. For example, in the
[clang docs](https://lld.llvm.org/missingkeyfunction.html):
> When a class has no non-pure, non-inline, virtual functions, there is no
key function, and the compiler is forced to emit the vtable in every
translation unit that references the class. In this case, it is emitted in a
COMDAT section, which allows the linker to eliminate all duplicate copies. This
is still wasteful in terms of object file size and link time, so it’s always
advisable to ensure there is at least one eligible function that can serve as
the key function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]