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

Accepts-invalid with dependent name not prefixed with typename #17283

Open
efriedma-quic opened this issue Aug 16, 2013 · 7 comments
Open

Accepts-invalid with dependent name not prefixed with typename #17283

efriedma-quic opened this issue Aug 16, 2013 · 7 comments
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] regression

Comments

@efriedma-quic
Copy link
Collaborator

efriedma-quic commented Aug 16, 2013

Bugzilla Link 16909
Version unspecified
OS Windows NT
CC @hyp,@benlangmuir,@DougGregor

Extended Description

Testcase:

template <typename,typename>
struct base {
  template <typename> struct derived;
};
template <typename T, typename U, typename V> base<T, U>::derived<V> foo();

We should print an error about the missing typename and template keywords.

@benlangmuir
Copy link
Collaborator

benlangmuir commented Jan 23, 2015

This can also cause assertion failures or generate invalid IR:

template<typename T> struct A {
  template<typename U> struct B {};
};
struct C {};
template<typename T> A<T>::B<T> begin(const T &);

void test() {
  auto __begin = begin(5); // asserts because we didn't deduce the type of __begin
  for (auto &&x : C()); // without assertions, will produce invalid LLVM IR
}

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 16, 2016

This is also tracked as rdar://problem/19438432.

Ben proposed a patch:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150126/122055.html

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@Endilll Endilll added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer worksforme Resolved as "works for me" crash Prefer [crash-on-valid] or [crash-on-invalid] labels Jun 25, 2023
@Endilll
Copy link
Contributor

Endilll commented Jun 25, 2023

Diagnostics is emitted since Clang 5: https://godbolt.org/z/1K786Tan4
Crash doesn't reproduce with assertion builds of Clang 3.5 and 3.6: https://godbolt.org/z/dErrdM4hd

@Endilll Endilll closed this as completed Jun 25, 2023
@efriedma-quic
Copy link
Collaborator Author

The following still crashes:

template<typename T> struct A {
  template<typename U> struct B {};
};
struct C {};
template<typename T> A<T>::B<T> begin(const T &);

void test() {
  auto __begin = begin(5); // asserts because we didn't deduce the type of __begin
}

@efriedma-quic efriedma-quic reopened this Jun 26, 2023
@Endilll
Copy link
Contributor

Endilll commented Jun 26, 2023

Crash appears to be fixed in Clang 5: https://godbolt.org/z/bbsvE68MT
But it's back since Clang 16: https://godbolt.org/z/hMMofvGM7

@Endilll Endilll added regression confirmed Verified by a second party and removed worksforme Resolved as "works for me" labels Jun 26, 2023
@efriedma-quic efriedma-quic added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer labels Jun 26, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 26, 2023

@llvm/issue-subscribers-clang-frontend

@efriedma-quic
Copy link
Collaborator Author

I think what happened is that we added a check to reject this... but when we implemented the C++20 typename rules in https://reviews.llvm.org/D53847, the check was relaxed, so this issue showed up again.

CC @alanzhao1 @cor3ntin @erichkeane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] regression
Projects
None yet
Development

No branches or pull requests

4 participants