[Development] (Bikeshed, pedantic) East constexpr vs West constexpr

Thiago Macieira thiago.macieira at intel.com
Wed Sep 18 22:29:06 CEST 2024


On Wednesday 18 September 2024 13:00:38 GMT-7 Mathias Hasselmann via 
Development wrote:
> Why that "inline" attributes at all? For functions and static data
> members the "constexpr" attribute implies "inline" already:
> https://timsong-cpp.github.io/cppwp/n4861/dcl.constexpr
> 
> What's the reason for this excessive use of redudant "inline" attributes?

Because unfortunately we've found out that it isn't enough and thus not 
redundant.

1) the implicit "inline" does not apply to template specialisations, so you 
must remember it in those
See a06f3e823bea0361125a10dd361f6fd50a4041cc

2) Clang emits "unused variable" for non-template constexpr, but not for 
constexpr inline
See https://gcc.godbolt.org/z/hEjzfdz1n
It also emits if you add static, but that's true for all static variables

Therefore, our constexpr variables should be explicitly inline too, to avoid 
those problems. The question is only the order in which we spell those two 
keywords out.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240918/23f7c85b/attachment-0001.bin>


More information about the Development mailing list