Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

ICE explicit calling a caputered lambda expression with a paramater pack #49215

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR50246
Status NEW
Importance P normal
Reported by Peter Georg (Peter.Georg@physik.uni-regensburg.de)
Reported on 2021-05-06 10:30:15 -0700
Last modified on 2021-08-26 06:37:45 -0700
Version unspecified
Hardware PC Linux
CC htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments backtrace.log (9798 bytes, text/x-log)
clang-bug-91043c.cpp (151 bytes, text/x-c++src)
clang-bug-91043c.sh (1936 bytes, application/x-shellscript)
Blocks
Blocked by
See also
Created attachment 24835
Crash backtrace

See reduced test-case on Compiler Explorer: https://godbolt.org/z/G4qT3sEf9

According to Compiler Explorer all clang versions (supporting the required
C++11/14 features) are affected by this bug.

clang frontend crashes when explicitly calling a captured lambda expression's
operator() using a parameter pack as arguments. The issue has been observed in
a larger code base in a more complex scenario using the familiar template
syntax for generic lambdas introduced in C++20.

Luckily I've been able to reduce the code to just a few meaning-less lines of
code still showing the same compiler error. While I have been able to rewrite
it using only C++11, the attached reduced code is written using C++14 features.
It just seems easier to understand and removes probably unrelated code.

Code to reproduce:

int main() {
  {
    auto const f = [](auto...) {};
    [f](auto const... ops) { f.operator()(ops...); }();
  }
}

My tests have shown that in line 4 of the code to reproduce the bug will only
show if all following three conditions are met:
1. The lambda expression f is captured. I.e. not defined within the other
unnamed lambda expression.
2. The lambda expression f is called via explicitly specifying .operator()
3. A parameter pack expansion is used as the arguments for calling the lambda
expression f. The size of the parameter pack does not matter, may be empty.

Attachements:
Crash backtrace, preprocessed source(s), and run script produced on local
machine with clang 11.
Quuxplusone commented 3 years ago

Attached backtrace.log (9798 bytes, text/x-log): Crash backtrace

Quuxplusone commented 3 years ago

Attached clang-bug-91043c.cpp (151 bytes, text/x-c++src): Preprocessed source(s)

Quuxplusone commented 3 years ago

Attached clang-bug-91043c.sh (1936 bytes, application/x-shellscript): run script

Quuxplusone commented 3 years ago
Some update testing newer clang versions:

clang 13 is still affected by this bug.

Testing with clang 14.0.0 (a45d72e0247d080eb9437736bb6cadfc27e4c065):
When compiling with --std=c++14 there is no ICE anymore.
Compiling with --std=c++17 or --std=c++20 there is still an ICE.