Skip to content

Assertion `!isa<ElaboratedType>(T) && "Elaborated type in nested-name-specifier"' #92757

Open
@dianqk

Description

@dianqk

I tried the following code with clang (assertions):

Details

namespace std {
typedef long unsigned int size_t;
typedef decltype(nullptr) nullptr_t;

template <typename _Tp> class reference_wrapper;
template <typename _Tp, _Tp __v> struct integral_constant {
  static constexpr _Tp value = __v;
  using value_type = _Tp;
  using type = integral_constant<_Tp, __v>;
  constexpr operator value_type() const noexcept { return value; }
  constexpr value_type operator()() const noexcept { return value; }
};
template <bool __v> using __bool_constant = integral_constant<bool, __v>;
using true_type = __bool_constant<true>;
using false_type = __bool_constant<false>;
template <bool, typename _Tp = void> struct enable_if {};
template <typename _Tp> struct enable_if<true, _Tp> {
  using type = _Tp;
};
template <typename _Tp, typename _Up = _Tp &&> _Up __declval(int);
template <typename _Tp> _Tp __declval(long);
template <typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0));
template <bool _Cond, typename _Tp = void>
using enable_if_t = typename enable_if<_Cond, _Tp>::type;
} // namespace std

template <class T> struct type {};
template <typename Iterator> class fragmented_memory_input_stream {};
template <typename Iterator> class memory_input_stream {
public:
  using fragmented_type = fragmented_memory_input_stream<Iterator>;
  fragmented_type _fragmented;

public:
  template <typename StreamVisitor>
  decltype(auto) with_stream(StreamVisitor &&visitor) const {
    return visitor(_fragmented);
  }
  using has_with_stream = std::true_type;
};
template <typename Stream, typename StreamVisitor,
          typename = std::enable_if_t<Stream::has_with_stream::value>>
decltype(auto) with_serialized_stream(Stream &stream, StreamVisitor &&visitor) {
  return stream.with_stream(visitor);
}
template <typename Stream, typename StreamVisitor,
          typename = std::enable_if_t<!Stream::has_with_stream::value>,
          typename = void>
decltype(auto) with_serialized_stream(Stream &stream, StreamVisitor &&visitor);
class fragment_iterator {};
template <typename T> struct serializer;
template <typename T, typename Input> T deserialize(Input &in, type<T> t);
using input_stream = memory_input_stream<fragment_iterator>;
struct mutation_partition_view {};
struct canonical_mutation_view {
  input_stream v;
  auto partition() const {
    return with_serialized_stream(
        v,
        [this](
            auto &v) -> decltype(deserialize(std::declval<input_stream &>(),
                                             type<mutation_partition_view>())) {
          auto in = v;
          return deserialize(in, type<mutation_partition_view>());
        });
  }
};

I got the following assertion:

1.	schema_tables.cpp:65:10: current parser token ')'
2.	schema_tables.cpp:55:1: parsing struct/union/class body 'canonical_mutation_view'
3.	schema_tables.cpp:57:26: parsing function body 'canonical_mutation_view::partition'
4.	schema_tables.cpp:57:26: in compound statement ('{}')
...
#10 0x00007f5fa1721560 llvm::PointerIntPairInfo<void*, 1u, llvm::pointer_union_detail::PointerUnionUIntTraits<clang::Type const*, clang::ExtQuals const*>>::updatePointer(long, void*) /home/dianqk/llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:202:5
#11 0x00007f5fa1721560 llvm::PointerIntPair<void*, 1u, int, llvm::pointer_union_detail::PointerUnionUIntTraits<clang::Type const*, clang::ExtQuals const*>, llvm::PointerIntPairInfo<void*, 1u, llvm::pointer_union_detail::PointerUnionUIntTraits<clang::Type const*, clang::ExtQuals const*>>>::setPointerAndInt(void*, int) & /home/dianqk/llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:111:29
#12 0x00007f5fa1721560 llvm::PointerIntPair<void*, 1u, int, llvm::pointer_union_detail::PointerUnionUIntTraits<clang::Type const*, clang::ExtQuals const*>, llvm::PointerIntPairInfo<void*, 1u, llvm::pointer_union_detail::PointerUnionUIntTraits<clang::Type const*, clang::ExtQuals const*>>>::PointerIntPair(void*, int) /home/dianqk/llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:89:5
#13 0x00007f5fa1721560 llvm::pointer_union_detail::PointerUnionMembers<llvm::PointerUnion<clang::Type const*, clang::ExtQuals const*>, llvm::PointerIntPair<void*, 1u, int, llvm::pointer_union_detail::PointerUnionUIntTraits<clang::Type const*, clang::ExtQuals const*>, llvm::PointerIntPairInfo<void*, 1u, llvm::pointer_union_detail::PointerUnionUIntTraits<clang::Type const*, clang::ExtQuals const*>>>, 0, clang::Type const*, clang::ExtQuals const*>::PointerUnionMembers(clang::Type const*) /home/dianqk/llvm/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:77:16

This code is from #91312 (comment).

The output from creduce:

namespace std {
      template <typename _Tp, _Tp __v> struct integral_constant {
       static constexpr _Tp value = __v;
     };
      template <bool __v> using __bool_constant = integral_constant<bool, __v>;
      using true_type = __bool_constant<true>;
      template <bool, typename _Tp = void> struct enable_if {
    };
      template <typename _Tp> _Tp __declval(long);
      template <typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0));
      template <bool _Cond, typename _Tp = void> using enable_if_t = typename enable_if<_Cond, _Tp>::type;
        namespace seastar {
      template <class T> struct type {
   };
      template <typename Iterator> class memory_input_stream {
    public:   using fragmented_type = fragmented_memory_input_stream<Iterator>;
      using has_with_stream = std::true_type;
    };
      template <typename Stream, typename StreamVisitor,           typename = std::enable_if_t<Stream::has_with_stream::value>> decltype(auto) with_serialized_stream(Stream &stream, StreamVisitor &&visitor) {
    }
        class fragment_iterator {
      namespace ser {
    template <typename T, typename Input> T deserialize(Input &in, seastar::type<T> t);
      using input_stream = seastar::memory_input_stream<fragment_iterator>;
     struct mutation_partition_view {
     input_stream v;
     auto partition() const {
      return seastar::with_serialized_stream(         v,         [this](auto &v) -> decltype(ser::deserialize(                             std::declval<input_stream &>(),                             seastar::type<mutation_partition_view>())) {
         }
 );

godbolt 1: https://llvm.godbolt.org/z/6sd8he1Me
godbolt 2: https://llvm.godbolt.org/z/jqfnKz47d

Metadata

Metadata

Assignees

Labels

c++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrash-on-valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions