[clang] Add thousands-separator to "cannot allocate array; evaluated array bound [...] exceeds the limit" diagnostic
E.g. for
constexpr int foo() {
auto p = new int[1'048'577];
delete[] p;
return 0;
}
static_assert(foo() == 0);
we emit
a.cpp:10:15: error: static assertion expression is not an integral constant expression
10 | static_assert(foo() == 0);
| ^~~~~~~~~~
a.cpp:5:20: note: cannot allocate array; evaluated array bound 1048577 exceeds the limit (1048576); use '-fconstexpr-steps' to
increase this limit
5 | auto p = new int[1'048'577];
| ^
a.cpp:10:15: note: in call to 'foo()'
10 | static_assert(foo() == 0);
It would be nice to
- Add thousands-separators to both the given size and the limit
- Change the wording to "exceeds the limit of xyz" to avoid the parantheses.
@llvm/issue-subscribers-clang-frontend
Author: Timm Baeder (tbaederr)
constexpr int foo() {
auto p = new int[1'048'577];
delete[] p;
return 0;
}
static_assert(foo() == 0);
we emit
a.cpp:10:15: error: static assertion expression is not an integral constant expression
10 | static_assert(foo() == 0);
| ^~~~~~~~~~
a.cpp:5:20: note: cannot allocate array; evaluated array bound 1048577 exceeds the limit (1048576); use '-fconstexpr-steps' to
increase this limit
5 | auto p = new int[1'048'577];
| ^
a.cpp:10:15: note: in call to 'foo()'
10 | static_assert(foo() == 0);
It would be nice to
- Add thousands-separators to both the given size and the limit
- Change the wording to "exceeds the limit of xyz" to avoid the parantheses.
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
- Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally. Be aware that LLVM's AI policy forbids the use of AI tools to fix good first issues since it squanders a learning opportunity. Using LLMs to search and learn is permitted, since the goal is learning.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Timm Baeder (tbaederr)
constexpr int foo() {
auto p = new int[1'048'577];
delete[] p;
return 0;
}
static_assert(foo() == 0);
we emit
a.cpp:10:15: error: static assertion expression is not an integral constant expression
10 | static_assert(foo() == 0);
| ^~~~~~~~~~
a.cpp:5:20: note: cannot allocate array; evaluated array bound 1048577 exceeds the limit (1048576); use '-fconstexpr-steps' to
increase this limit
5 | auto p = new int[1'048'577];
| ^
a.cpp:10:15: note: in call to 'foo()'
10 | static_assert(foo() == 0);
It would be nice to
- Add thousands-separators to both the given size and the limit
- Change the wording to "exceeds the limit of xyz" to avoid the parantheses.
@tbaederr ping for review
Hey is anyone working on this if not could I take it up?
Hi, if anyone is not working on this, I would like to take it up!
there's already a PR open for this issue
there's already a PR open for this issue
For future reference, if you are taking up a good first issue it is helpful to indicate you plan to work on it and also indicate when a PR is opened for it. Good first issuses get a lot of attention and it helps to avoid extra comments and wasted work.
Hi! I'm planning to work on this issue as part of the CS3423 Compilers II hackathon at IIT Hyderabad. I'd like to take responsibility for implementing the diagnostic formatting change and adding the corresponding regression tests. Could a maintainer please assign this issue to me? Thank you!
Hi! I'm planning to work on this issue as part of the CS3423 Compilers II hackathon at IIT Hyderabad. I'd like to take responsibility for implementing the diagnostic formatting change and adding the corresponding regression tests. Could a maintainer please assign this issue to me? Thank you!
There's already a pr open, just have to address the review comments to merge it