Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine as a fix, though ideally, it would be good to know what’s causing this so it’s easier to figure out what’s going wrong; my assumption is that we do something to the pack that causes
IsExpandedto be true here but which wouldn’t have been true at the timeFixedNumExpansionswas (not) set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an assert:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot be the solution.
FixedNumExpansionsis nullopt. Why is1an improvement over nullopt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assert is not necessary, unless it added explanation.
The
*operator on the optional here should already assert in that case.I would advise you run this test case on an llvm build with runtime checks enabled. The compiler is going off the rails before this point, so maybe there is an earlier assert that could narrow it down.
Otherwise, the change lacks explanation, about what is the problem, and what the fix does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A similar approach seems to be used in
getPackIndexForParamas wellSince
getExpandedPackSizemight returnnullopt, I assumed the template parameter not being a pack is a valid case and not a bug. Perhaps we can doin
addPackinstead to make it more neat?I opened this PR thinking that this was a simple issue, but if this is a deeper bug, we can look at ->
Here,
Param->isTemplateParameterPack()seems to return true, whilegetExpandedPackSizereturnsnulloptThis is because
isTemplateParameterPackchecks whether the given parameter is aisParameterPackor not, whilegetExpandedPackSizechecks forisExpandedParameterPack. In this specific case, former returns true while the latter returns false, so either the parameter is wrongly marked as a parameter pack, or it is not expanded whenPackDeductionScopeis constructed in `ConvertDeducedTemplateArguments'?If this is indeed a deeper bug than I first thought and
PackDeductionScopegetting constructed with aParamthat is not anisExpandedParameterPackis an issue, I think there is a missingTryExpandParameterPackscall at the TreeTransform stage? I am quite new to codebase so this is just a guess.Please give me your opinion regarding this, and I will continue investigating this further depending on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I’m unfortunately not familiar enough w/ this part of Clang to comment on whether that’s the case or not; I’d have to look into this a bit more.
CC @AaronBallman, @erichkeane
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a great idea here either. It seems to me that we shouldnt get here without a pack, and the bug is sooner, but I dont have a great idea of where we should be catching that case.