-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Undiagnosed implementation limit of 127 nested function prototypes #19981
Comments
Relatedly, we cap out at 2**15 function parameters: $ cat t.py $ python t.py | clang -c -x c - |
*** Bug llvm/llvm-bugzilla-archive#33162 has been marked as a duplicate of this bug. *** |
I created a patch [1] for the original submission, will look at the second part later. |
Looking at FunctionTypeBitfields, It looks like the limits now for the number of function parameters is 2^16-1. It would be possible to bump this a little bit since there is some space left in FunctionTypeBitfields (but [implimits] only ask for 8 bits...) I wonder if it would be worth spending some time going through the various limits and :
|
I think that would be better, also avoids confusing error messages like in bug 33162, where the error referred to an existing identifier.
I assume that should be part of the patch introducing the error message.
According to [implimits] "Every implementation shall document those limitations where known." so I think that should be done. |
I would definitely support both documenting and enforcing these limits. I don't think we should bump them unless we actually think they're currently unacceptable. |
*** Bug llvm/llvm-bugzilla-archive#31968 has been marked as a duplicate of this bug. *** |
*** Bug #11122 has been marked as a duplicate of this bug. *** |
mentioned in issue llvm/llvm-bugzilla-archive#31968 |
mentioned in issue llvm/llvm-bugzilla-archive#33162 |
The first test case appears to be fixed in Clang 10: https://godbolt.org/z/szcM4cfG3 |
Extended Description
ParmVarDecl::setScopeInfo() is defined like so:
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex) {
assert(!ParmVarDeclBits.IsObjCMethodParam);
ParmVarDeclBits.ScopeDepthOrObjCQuals = scopeDepth;
assert(ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth
&& "truncation!");
setParameterIndex(parameterIndex);
}
It's possible to construct a program that trips this assertion by creating a deeply nested function prototype:
void foo(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
Assertion failed: ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth && "truncation!", file ..\tools\clang\include\clang/AST/Decl.h, line 1276
I wanted one more bit in VarDeclBits.TSCSpec, so I considered taking it from here. However, I discovered we don't enforce an upper bound on this quantity.
The text was updated successfully, but these errors were encountered: