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

[clang] Constraint normalization uses too much memory #122581

Open
cookiestarfish opened this issue Jan 11, 2025 · 3 comments
Open

[clang] Constraint normalization uses too much memory #122581

cookiestarfish opened this issue Jan 11, 2025 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts

Comments

@cookiestarfish
Copy link

template <typename T>
concept C0 = true;

template <typename T>
concept C1 = true;

template <typename T>
concept C2 = true;

template <typename T>
concept C3 = true;

template <typename T>
concept C4 = true;

template <typename T>
concept X =
    (C0<T> && (C2<T> && C3<T>) || (C2<T> && C4<T>) || (C3<T> && C4<T>)) ||
    (C0<T> && (C1<T> && C2<T>) ||
     (C1<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>)) ||
     (C2<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>))) ||
    ((C2<T> && C3<T>) || (C2<T> && C4<T>) ||
     (C3<T> && C4<T>) && (C1<T> && C2<T>) ||
     (C1<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>)) ||
     (C2<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>)));

template <typename T>
concept Y = C0<T> && X<T>;

int foo(X auto x) { return 10; }
int foo(Y auto y) { return 20; }

int bar() { return foo(0); }

https://godbolt.org/z/d1e8z7vvK

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 11, 2025
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts and removed clang Clang issues not falling into any other category labels Jan 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 11, 2025

@llvm/issue-subscribers-clang-frontend

Author: marco (cookiestarfish)

``` template <typename T> concept C0 = true;

template <typename T>
concept C1 = true;

template <typename T>
concept C2 = true;

template <typename T>
concept C3 = true;

template <typename T>
concept C4 = true;

template <typename T>
concept X =
(C0<T> && (C2<T> && C3<T>) || (C2<T> && C4<T>) || (C3<T> && C4<T>)) ||
(C0<T> && (C1<T> && C2<T>) ||
(C1<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>)) ||
(C2<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>))) ||
((C2<T> && C3<T>) || (C2<T> && C4<T>) ||
(C3<T> && C4<T>) && (C1<T> && C2<T>) ||
(C1<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>)) ||
(C2<T> && (C1<T> && C3<T>) || (C1<T> && C4<T>) || (C3<T> && C4<T>)));

template <typename T>
concept Y = C0<T> && X<T>;

int foo(X auto x) { return 10; }
int foo(Y auto y) { return 20; }

int bar() { return foo(0); }

https://godbolt.org/z/d1e8z7vvK
</details>

@zyn0217
Copy link
Contributor

zyn0217 commented Jan 11, 2025

Are you running a fuzzer to get this?

@cookiestarfish
Copy link
Author

Are you running a fuzzer to get this?

No, the function is the majority5 function, I used it because it blows up in size during normalization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts
Projects
None yet
Development

No branches or pull requests

4 participants