Skip to content

Conversation

@knightXun
Copy link
Contributor

@knightXun knightXun commented Oct 26, 2023

When template variables are variadic, sema may panic, potentially leading to a situation where the number of function variables exceeds the number of template variables.The sema compares the template signature and function signature parameters one by one, which can trigger an assertion error. This PR, when encountering variadic templates,
avoids comparing the template signature and function signature parameters one by one.

#70191

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 26, 2023
@knightXun knightXun changed the title [clang][Sema] Resolving Panic Caused by Inconsistent Arguments in Var… [clang][Sema] Resolving Inconsistent Arguments Panic in Variadic Template Variables Oct 26, 2023
@github-actions
Copy link

github-actions bot commented Oct 26, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

@knightXun
Copy link
Contributor Author

i will add test case for it

@cor3ntin
Copy link
Contributor

@knightXun code looks reasonable, ping me when you have tests and a release note :)

@knightXun
Copy link
Contributor Author

@knightXun code looks reasonable, ping me when you have tests and a release note :)
got it,

…iadic Template Variables

When template variables are variadic, sema may panic, potentially leading to a situation
 where the number of function variables exceeds the number of template variables.
The sema compares the template signature and function signature parameters one by one,
 which can trigger an assertion error. This PR, when encountering variadic templates,
avoids comparing the template signature and function signature parameters one by one.

issue: llvm#70191
@knightXun
Copy link
Contributor Author

cc @cor3ntin

Copy link
Collaborator

@shafik shafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cor3ntin do this still look good to you?

template <typename... c> void d(c...) = d<b, a>(0, ""); // expected-error {{no matching function for call to 'd'}}
// expected-error@-1 {{illegal initializer (only variables can be initialized)}}
// expected-note@-2 {{candidate function template not viable: no known conversion from 'const char[1]' to 'a' (aka 'int') for 2nd argument}}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing EOL

@cor3ntin
Copy link
Contributor

cor3ntin commented Apr 4, 2024

@shafik Yes. It needs to be rebased though
@knightXun I apologize for the long delay. In the future, feel free to ping if you don't get a reply after one or 2 weeks

@cor3ntin
Copy link
Contributor

Fixed by 7a28a5b

@cor3ntin cor3ntin closed this Jul 17, 2024
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" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants