-
Notifications
You must be signed in to change notification settings - Fork 975
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
std::tie does not work with derived classes under libc++ #578
Comments
The following works fine... #include <tuple>
using t = std::tuple<int,float,char>;
int main ()
{
int myint;
char mychar;
t tt;
std::tie (myint, std::ignore, mychar) = tt; // unpacking tuple into variables
} |
Ideas/workarounds are invited. |
What is worse is that I do not know how to test this in CI. I only found out because I sometimes run tests on my macbook. |
This is libc++ https://gcc.godbolt.org/z/VH55tH However, it's not tie but something in libc++'s tuple I think https://gcc.godbolt.org/z/csVXTE |
The problem: #include <tuple>
using t_base = std::tuple<int, float, char>;
struct t : t_base {};
int main() {
int myint;
char mychar;
t tt;
std::tie(myint, std::ignore, mychar) = static_cast<t_base&>(tt);
} The longer fix: |
Thank you folks. So we have identified the true source of the problem: libc++. This should make testing easier, at the least. @ThePhD's workaround (a cast to pair) can probably be made to look nice with some effort. |
We are now going to test with libc++ in CI. See #579 |
The bug is already open in libc++: https://reviews.llvm.org/D50106 There is a patch but it has been reviewed and blocked in January 2019 (over a year ago): https://reviews.llvm.org/D50106 I see no workaround being suggested. |
@ldionne can you help us? |
The two things I'm wondering:
Actually making simdjson_result == std::pair is possible but because we add methods to the class, I think we'd have to completely redefine it for that variant (e.g. |
My current understanding of C++ is that assignment operators cannot be static, they have to be defined in the class. In other programming languages like Swift, you can extend a class from the outside, so it would not be a problem, but in C++ you cannot. So if you want to redefine how this get compiled...
... you have to have some control on the class 'a' belongs to. And we do not. So I don't see how we can fix this by hacking the operator assignment. |
@jkeiser Maybe we can close this... I don't think that the libc++ folks are going to be rushing in to offer workarounds... |
Ok. I am closing this issue. |
FWIW we fixed this in:
|
Merci @ldionne C'était vraiment énervant. :-) |
Apple has its own version of LLVM's clang which should follow closely clang, but often differs slightly. Unfortunately, many programmers are mac users so it is inconvenient to leave macOS users in the cold.
The following won't build under macOS:
The error is as follows...
cc @jkeiser
The text was updated successfully, but these errors were encountered: