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 empty parameter pack on variadic concept as return type constraint #47961

Closed
llvmbot opened this issue Dec 28, 2020 · 7 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla c++20

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 28, 2020

Bugzilla Link 48617
Resolution FIXED
Resolved on Oct 11, 2021 20:29
Version trunk
OS Linux
Blocks #51489
Reporter LLVM Bugzilla Contributor
CC @LebedevRI,@mizvekov,@zygoloid,@tstellar
Fixed by commit(s) 68b9d8e 02dece0

Extended Description

https://godbolt.org/z/6KE9ed

If a constraint on a return type ends up being given zero parameters for its parameter pack, clang blows up with a very confusing crash and no useful diagnostic. In addition, in certain situations if you explicitly specialize the function template before calling it again without explicit template arguments, the second inferred call will compile but only if preceded by the first call with explicit args. Unfortunately I do not have a minimal repro of this case yet but it is the way I initially encountered this bug.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 28, 2020

assigned to @mizvekov

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 28, 2020

Nevermind about the comment about explicit template args; that has to do with things relating to overloads and conversions in the specific code I was working with that would take a lot more code to demonstrate here and aren't core to the crash at hand.

@tstellar
Copy link
Collaborator

This bug was not resolved in time for the 12.0.0 release, so it will have to wait for 12.0.1.
If you feel this is a high-priority bug that should be fixed for 12.0.0, please re-add
release-12.0.0 to the Blocks field and add a comment explaining why this is high-priority.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Sep 7, 2021

The behavior has nearly reversed since the 12 release. Now:

The lines labeled // 3... and // 2... both crash (with different backtraces!) and the lines labeled // 1... and // BANG! both work properly.

@mizvekov
Copy link
Contributor

mizvekov commented Sep 7, 2021

Reduced example, showing some extra problems:

template <typename...> class a {};
template <typename...> concept g = true;
template <typename... d> g<d...> auto e(a<d...>) { return 0; }

#if   BUG == 0

  template g<int> auto e<int>(a<int>); // Clang fails to instantiate this

#elif BUG == 1

  template g<> auto e<>(a<>); // Clang crashes

#elif BUG == 2
  
  // Same as above, but it instantiates 'e' when it shouldn't.
  template auto e<>(a<>);

#elif BUG == 3

  // Get around BUG 0, since we can't just instantiate this.
  // Clang has a different crash this time.
  template <typename... b> a<b...> c(b...);
  int f = e(c(1, 2));

#endif

CE Workspace: https://godbolt.org/z/zK7E9nMfb

@tstellar
Copy link
Collaborator

tstellar commented Sep 8, 2021

Merged: 02dece0

@tstellar
Copy link
Collaborator

mentioned in issue #51489

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
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++20
Projects
None yet
Development

No branches or pull requests

3 participants