Skip to content

Commit

Permalink
Fix ODR violation for IsFloatType_v
Browse files Browse the repository at this point in the history
With recent GCC 15 trunk, I started to see:
```
ld: .../kwalletentry.cc.o:(.rodata+0x0): multiple definition of `QtPrivate::IsFloatType_v<_Float16>';
	src/runtime/kwalletd/backend/CMakeFiles/KF6WalletBackend.dir/cbc.cc.o:(.rodata+0x0): first defined here
```

The issue is that constexpr is only implicitly inline for functions or
static data members [0], so the constexpr IsFloatType_v specialization
here causes an ODR violation.

Explicitly mark the specialization as inline constexpr.

[0] http://eel.is/c++draft/dcl.constexpr#1.sentence-3

Fixes: 4b755bc
Pick-to: 6.8 6.7
Change-Id: Ie9257138f6d1218ca0a91f5d114aab2483cb275b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
  • Loading branch information
thesamesam committed Aug 23, 2024
1 parent a74b550 commit a06f3e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/corelib/global/qcomparehelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ constexpr bool IsFloatType_v = std::is_floating_point_v<T>;

#if QFLOAT16_IS_NATIVE
template <>
constexpr bool IsFloatType_v<QtPrivate::NativeFloat16Type> = true;
inline constexpr bool IsFloatType_v<QtPrivate::NativeFloat16Type> = true;
#endif

} // namespace QtPrivate
Expand Down

0 comments on commit a06f3e8

Please sign in to comment.