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

Crash with stack trace, trying to get insight about std::tuple #188

Closed
jorgbrown opened this issue May 31, 2019 · 4 comments
Closed

Crash with stack trace, trying to get insight about std::tuple #188

jorgbrown opened this issue May 31, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@jorgbrown
Copy link

The real version I wanted the insight on can be seen at https://godbolt.org/z/YUbnZG , which is just https://godbolt.org/z/sZgc7p but with the header sources pulled in.

Anyway, in cppinsights.io, those crash... so I kept reducing them until I got to:

https://godbolt.org/z/keppKm
that is,
https://cppinsights.io/lnk?code=I2luY2x1ZGUgPGJpdHMvYysrY29uZmlnLmg+CiNpbmNsdWRlIDxiaXRzL21vdmUuaD4KCiNpbmNsdWRlIDxjc3RkZGVmPgoKI2RlZmluZSBfR0xJQkNYWF9UVVBMRSAxCgpuYW1lc3BhY2Ugc3RkIHsKX0dMSUJDWFhfQkVHSU5fTkFNRVNQQUNFX1ZFUlNJT04KCnRlbXBsYXRlIDxzdGQ6OnNpemVfdCBfSWR4LCB0eXBlbmFtZSBfSGVhZCwgYm9vbCBfSXNFbXB0eU5vdEZpbmFsPgpzdHJ1Y3QgX0hlYWRfYmFzZTsKCnRlbXBsYXRlIDxzdGQ6OnNpemVfdCBfSWR4LCB0eXBlbmFtZSBfSGVhZD4Kc3RydWN0IF9IZWFkX2Jhc2U8X0lkeCwgX0hlYWQsIHRydWU+IDogcHVibGljIF9IZWFkIHsKICBjb25zdGV4cHIgX0hlYWRfYmFzZSgpIDogX0hlYWQoKSB7fQogIGNvbnN0ZXhwciBfSGVhZF9iYXNlKGNvbnN0IF9IZWFkJiBfX2gpIDogX0hlYWQoX19oKSB7fQogIGNvbnN0ZXhwciBfSGVhZF9iYXNlKGNvbnN0IF9IZWFkX2Jhc2UmKSA9IGRlZmF1bHQ7Cn07Cgp0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kKF9faW4pKSB7fQp9OwoKX0dMSUJDWFhfRU5EX05BTUVTUEFDRV9WRVJTSU9OCn0KCi8vIHN0ZDo6X1R1cGxlX2ltcGw8MSwgc2hvcnQsIGxvbmc+IG9uZV9zX2w7Cg==&insightsOptions=cpp17&std=cpp17&rev=1.0

And in case that breaks in the future, here's the actual source I used, with C++17 selected as my standard:

#include <bits/c++config.h>
#include <bits/move.h>

#include <cstddef>

#define _GLIBCXX_TUPLE 1

namespace std {
_GLIBCXX_BEGIN_NAMESPACE_VERSION

template <std::size_t _Idx, typename _Head, bool _IsEmptyNotFinal>
struct _Head_base;

template <std::size_t _Idx, typename _Head>
struct _Head_base<_Idx, _Head, true> : public _Head {
  constexpr _Head_base() : _Head() {}
  constexpr _Head_base(const _Head& __h) : _Head(__h) {}
  constexpr _Head_base(const _Head_base&) = default;
};

template <std::size_t _Idx, typename _Head>
struct _Head_base<_Idx, _Head, false> {
  constexpr _Head_base() : _M_head_impl() {}
  constexpr _Head_base(const _Head& __h) : _M_head_impl(__h) {}
  constexpr _Head_base(const _Head_base&) = default;

  _Head _M_head_impl;
};
  
template <std::size_t _Idx, typename... _Elements>
struct _Tuple_impl;

template <std::size_t _Idx>
struct _Tuple_impl<_Idx> {
  template <std::size_t, typename...>
  friend class _Tuple_impl;

  _Tuple_impl() = default;
};

template <typename _Tp>
struct __is_empty_non_tuple : is_empty<_Tp> {};

template <typename _El0, typename... _El>
struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type {};

template <typename _Tp>
using __empty_not_final = typename conditional<__is_final(_Tp), false_type, __is_empty_non_tuple<_Tp>>::type;

template <std::size_t _Idx, typename _Head, typename... _Tail>
struct _Tuple_impl<_Idx, _Head, _Tail...>
    : public _Tuple_impl<_Idx + 1, _Tail...>,
      private _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> {

  typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
  typedef _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> _Base;

  constexpr _Tuple_impl() : _Inherited(), _Base() {}

  explicit constexpr _Tuple_impl(const _Head& __head, const _Tail&... __tail)
      : _Inherited(__tail...), _Base(__head) {}

  template <typename... _UElements>
  constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
      : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
        _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) {}
};

_GLIBCXX_END_NAMESPACE_VERSION
}

// std::_Tuple_impl<1, short, long> one_s_l;

When I push the play button, I get this in the console:

insights: /usr/lib/llvm-8/include/clang/AST/ExprCXX.h:3383: clang::Expr* clang::CXXDependentScopeMemberExpr::getBase() const: Assertion `!isImplicitAccess()' failed.
[0x13415bf]
[0x133f9e2]
[0x1341b18]
[0x136a030]
[0x1369fd7]
[0x142bd81]
[0x141f35c]
[0x141f3d2]
[0x4220ca]
[0x405dbc]
[0x411ac4]
[0x409ef1]
[0x4110c4]
[0x408ea1]
[0x411b44]
[0x40d621]
[0x40d964]
[0x4086f4]
[0x40f08f]
[0x410962]
[0x40faea]
[0x46596c]
[0x4c5ad1]
[0x4db0fb]
[0x4c538d]
[0x4ca0bc]
[0x4c945d]
[0x4ca0c7]
[0x4c945d]
[0x4b0120]
[0x47d293]
[0x7b8783]
[0x53b6af]
[0x4fc6b8]
[0x4a1316]
[0x4a1086]
[0x4a052f]
[0x4a27f4]
[0x47bb06]
[0x141b679]
[0x4055aa]
Aborted (core dumped)

@andreasfertig
Copy link
Owner

Hello @jorgbrown,

thank you for reporting that. And a special thanks for reducing it to the minimum.
This triggers a Clang assertion. I have a fix to prevent it crashing but not to generate valid code. I will look in to it more.

Andreas

@stale
Copy link

stale bot commented Aug 1, 2019

Thanks for contributing to this issue. As it has been 60 days since the last activity waiting for a followup. This issue will be automatically closed in 7 days, if no further activity occurs. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please respond before the issue is closed. We'll gladly take a look again! In any case, thank you for your contributions!

@stale stale bot added the stale No activity label Aug 1, 2019
@jorgbrown
Copy link
Author

"please respond before the issue is closed"

(because it still reproduces.)

@stale stale bot removed the stale No activity label Aug 2, 2019
@andreasfertig andreasfertig added the bug Something isn't working label Aug 2, 2019
@andreasfertig
Copy link
Owner

Hello @jorgbrown,

sorry, that is the stale bot on the loose. I will not close it. In fact, I already have a fix. I'm just not that happy with it.

Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants