Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Accessor functions for std::array<T,0> aren't constexpr #1630

Closed
sunnlok opened this issue Dec 15, 2021 · 1 comment
Closed

[BUG] Accessor functions for std::array<T,0> aren't constexpr #1630

sunnlok opened this issue Dec 15, 2021 · 1 comment
Labels

Comments

@sunnlok
Copy link

sunnlok commented Dec 15, 2021


Description

Accessor functions for std::array<T,0> aren't constexpr.
This means that std::array can not be used in a constexpr context if its, for example, used to initialize a span, which might or might not be empty depending on other compile time evaluated factors.

Current implementation:
_LIBCPP_INLINE_VISIBILITY value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);} _LIBCPP_INLINE_VISIBILITY const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);}

Fixed in LLV since version 11:

https://github.com/llvm/llvm-project/blob/release/11.x/libcxx/include/array

@sunnlok sunnlok added the bug label Dec 15, 2021
@DanAlbert
Copy link
Member

Duplicate of #1530

@DanAlbert DanAlbert marked this as a duplicate of #1530 Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants