-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
issue compiling code with large constexpr arrays of function pointers #71888
Comments
@llvm/issue-subscribers-clang-frontend Author: None (wheatman)
I am trying to make some large constexpr arrays of functions pointers, but when they get to a certain size they just seem to break and starts giving error messages about parts of the code which doesn't change with the size.
The code can be found at working with a size of broken with a size of the timeouts from g++ are just from godbolt, when I compile the same code on my own machine it does finish without errors with g++ The code has been simplified down to
The error with the code that has 16 instead of 15 is
I first guessed the issue had to do with one of the limits here https://clang.llvm.org/docs/UsersManual.html#controlling-implementation-limits However, all but |
Tracked this down to llvm-project/clang/include/clang/AST/ExprCXX.h Line 4446 in 5c36f43
Which we never check for before creating the expression. |
It looks like the 32 bit to 16 bit conversion happens here llvm-project/clang/lib/AST/ExprCXX.cpp Line 1682 in 5c36f43
I feel like there should at least be some sort of error raised here instead of just silently cutting off the high bits. Also, I can't find anything in the standard about the max size of a pack, seems to just say zero or more, so it would be nice if instead NumArguments could be made 32 bits |
I added a patch to add the assert when the conversion happens as a temporary fix, this may also lead to some discovery if this case is common enough that large packs should be supported, I imagine they may be some time and space overhead of supporting larger packs |
I am trying to make some large constexpr arrays of functions pointers, but when they get to a certain size they just seem to break and starts giving error messages about parts of the code which doesn't change with the size.
The code can be found at
working with a size of
1<<15
https://godbolt.org/z/15badTccs
broken with a size of
1<<16
https://godbolt.org/z/KMPGYbKcx
the timeouts from g++ are just from godbolt, when I compile the same code on my own machine it does finish without errors with g++
The code has been simplified down to
The error with the code that has 16 instead of 15 is
I first guessed the issue had to do with one of the limits here https://clang.llvm.org/docs/UsersManual.html#controlling-implementation-limits
However, all but
constexpr-steps
seem to small to be related and I tried increasing it with-fconstexpr-steps=134217728
and it had no effectThe text was updated successfully, but these errors were encountered: