Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

crash in function SubstituteExplicitTemplateArguments #22398

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR22399
Status NEW
Importance P normal
Reported by ryan.burn@gmail.com
Reported on 2015-01-29 23:14:56 -0800
Last modified on 2015-10-20 15:17:51 -0700
Version trunk
Hardware PC All
CC david.majnemer@gmail.com, llvm-bugs@lists.llvm.org, mattipee@yahoo.co.uk
Fixed by commit(s)
Attachments polynomial_optimization_test-e0a786.sh (678 bytes, application/x-sh)
polynomial_optimization_test-e0a786.cpp.gz (673837 bytes, application/x-gzip)
Blocks
Blocked by
See also

attached source and generation script

Quuxplusone commented 9 years ago

Attached polynomial_optimization_test-e0a786.sh (678 bytes, application/x-sh): generation script

Quuxplusone commented 9 years ago

Attached polynomial_optimization_test-e0a786.cpp.gz (673837 bytes, application/x-gzip): source code

Quuxplusone commented 9 years ago
reduction:
template <bool>
struct enable_if;
struct A {
  typedef int type;
  struct type_list {};
};
template <typename... TTags>
struct tuple_tags {
  typedef A::type_list tags;
  template <typename TTag>
  using index_of = tags;
};
template <typename... Args>
struct tagged_tuple {
  typedef tuple_tags<typename Args::tag...> tags;
};
template <typename... TTags>
tagged_tuple<tagged_tuple<TTags>...> make_tagged_tuple();

struct ValueA;
template <class Constraints,
          enable_if<Constraints::tags::template index_of<ValueA> == 0> = 0>
void minimize_constrained_quadratic(Constraints) {
  minimize_constrained_quadratic(make_tagged_tuple());
}

It could be better though...
Quuxplusone commented 8 years ago
Hit this (or something very like it) today - my reduced test code below.

Running a recent debug build, both the reduced test code posted above as well
as my own seem to fail with:

llvm/include/llvm/Support/Casting.h:237:

typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X =
clang::FunctionTemplateDecl, Y = clang::NamedDecl]: Assertion `isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!"' failed.

$ clang++ -v
clang version 3.8.0 (http://llvm.org/git/clang.git
3490ab8630d5643f71f1f04e46984f05b27b8d67) (http://llvm.org/git/llvm.git
d2643e2ff955ed234944fe3c6b4ffc1250085843)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...

template <typename T> struct A {
  static const int value = T::template F_t<int>; //nonsense
};

struct B {
  template <typename T> struct F { using type = T;};
  template <typename T> using F_t = typename F<T>::type;
};

int main() {
  return A<B>::value;
}