Skip to content

Clang frontend failed on parsing concept with packed parameters #45115

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 45770
Version 10.0
OS All
Attachments Clang generated bug description files
Reporter LLVM Bugzilla Contributor
CC @zygoloid,@saarraz

Extended Description

Clang frontend failed on parsing following minimized case:

template <typename T, typename U>
concept C1 = false;

template <typename T, typename ... Args>
concept C2 = sizeof...(Args) == 1 && C1<T, Args>;

template requires C2<T, int>
void f(T t) {}

int main() {
f(1);
return 0;
}

Steps to Reproduce:

Compile this snippet with command:

clang++-10 -std=c++20 main.cpp -o main

will cause the frontend to crash.

Expected Results:
It's obvious to find that code line concept C2 = sizeof...(Args) == 1 && C1<T, Args>; doesn't correctly unpacked the parameter pack, which should be corrected to:
concept C2 = sizeof...(Args) == 1 && (... && C1<T, Args>);
which will then compile correctly. It seems that the frontend has some defects preventing itself from handling such syntax error.

Additional Information:
The environment tested is WSL1 on Windows 10 2004 with Ubuntu-18.04, and the clang version is 10.0.0-++20200412073436+50d7e5d5e7d-1exp120200412054917.132. I've also tested on the Compiler Explorer website with clang 10 & clang (trunk) which all give the same result. G++ (trunk) can handle the error correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions