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
Multiple variable definition with Clang 9 #158
Comments
Thanks for the report! I thought that this variable template wasn't ODR-used since it is only used as a non-type template parameter, but apparently I'm still unable to predict ODR issues. I guess that I will do as you say and make it |
I can also remove the |
You're welcome :) Mmmh, it seems Clang allows to do a declaration of the specialized variable, and so always generates it (when not inlined): https://godbolt.org/z/NfvWzn |
Interestingly enough GCC allows to forward-declare the variable template as |
Haha yes, me too ! I didn't succeed with |
I did try that, haha. Apparently both compilers allow |
Yup, I think it's the best way to do it, and static variables have good chances to be optimized away anyway. I didn't know about the |
Also remove the specialization for std::input_iterator_tag since it doesn't make sense to call in-place sorting algorithms on input iterators. This notably allows to reduce the index of the other specializations.
The tests passed but I can't really test the fix with Clang 9 since it's not on Travis AFAIK. I'll close the issue for now, don't hesitate to reopen if needed :) |
I just found the recent CWG2433 (the link is probably not available yet) which says:
Apparently this DR is tentatively ready for the next meeting, and it looks like it directly concerns our issue here. |
Nice ! I don't have access to the link but it should correct this issue indeed :) |
Also remove the specialization for std::input_iterator_tag since it doesn't make sense to call in-place sorting algorithms on input iterators. This notably allows to reduce the index of the other specializations.
While there haven't been lots of ODR issues so far with namespace-scope constexpr variables (#158 being the exceptions), I would rather be safe than sorry. This commit either puts constexpr variables in functions or marks them inline to avoid ODR issues. While variable templates are supposed to be inline as per CWG2433, GCC and Clang document the DR support status as "unknown", so I decided to be conservative and to mark constexpr variable templates inline too.
I gave this issue another look for the C++20 branch of the project, but it seems that the status of CWG2433 support is still unknown/undocumented:
As a result I decided to be conservative and to mark all namespace-scope |
When compiling with Clang 9, I got
because it seems that Clang 9 does not treat template specializations of constexpr variables
inline
anymore. Because the library is in C++14, the specializations cannot be markedinline
so I think they should bestatic
instead.The text was updated successfully, but these errors were encountered: