-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Introduction of -fbracket-depth broke std::array:s longer than 256 #49522
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
Comments
(I should have said limiting the length of std::array being construced via deduction guide to <= 256.) |
@llvm/issue-subscribers-clang-frontend Author: None (4f99a97d-37e2-4b4f-939b-3f5760df598b)
| | |
| --- | --- |
| Bugzilla Link | [50178](https://llvm.org/bz50178) |
| Version | trunk |
| OS | Linux |
| CC | @DougGregor,@zygoloid |
Extended DescriptionThe code at the bottom behaves like this with clang-12: % clang++ -std=c++17 -c b.cpp
In file included from b.cpp:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include/g++-v10/array:245:52: fatal error: instantiating fold expression with 257 arguments exceeded expression nesting limit of 256
-> array<enable_if_t<(is_same_v<_Tp, _Up> && ...), _Tp>,
~~~~~~~~~~~~~~~~~~~~~~~~^~~~
b.cpp:6:12: note: while substituting deduced template arguments into function template '<deduction guide for array>' [with _Tp = S, _Up = <S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S>]
std::array a{S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
^
1 error generated.
% clang++ -std=c++17 -c -fbracket-depth=512 b.cpp
% echo $?
0 This actually hit our production code and took me a while to reduce. I think limiting the length of std::array to <= 256 by default is not desirable. This is the code: #include<array>
struct S {};
std::array a{S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{},
S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}, S{}}; |
confirming that this is still the case in post 17 trunk(5a56f00) code
error
|
This feels like it is behaving as expected: https://clang.llvm.org/docs/UsersManual.html#controlling-implementation-limits Although it might be nice for the diagnostic to point out more information. |
Yeah, I don't think this is actually a bug; it could be an enhancement request to support a bigger default value than 256, but unless a lot of users are hitting this issue, I think the current limit is reasonable (it's the same default as recommended by the standard in https://eel.is/c++draft/implimits#2.4). The diagnostic could be improved a bit because it's not obvious why bracket depth is involved (it's because a fold expression formally expands to a series of nested parenthesized expressions). |
Extended Description
The code at the bottom behaves like this with clang-12:
This actually hit our production code and took me a while to reduce. I think limiting the length of std::array to <= 256 by default is not desirable.
This is the code:
The text was updated successfully, but these errors were encountered: