[clang-tools-extra] [libcxx] Allow string to use SSO in constant evaluation. (PR #66576)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 8 17:07:28 PDT 2023


jyknight wrote:

Looks like the debug/hardened/safe mode tests are failing libcxx/std/utilities/template.bitset/bitset.members/to_string.pass.cpp because the constant evaluations for
```
  static_assert(test_to_string<64>());
  static_assert(test_to_string<65>());
```
now both hit the constant evaluation step limit. With the previous code, it would work until length 80 (after creating a get_test_cases<80> function with similar patterns), but with the new impl, 63 is the max in those modes.

I'm not sure whether we should care? I've fixed the test by splitting up the test function.

Sample failure:
```
# | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:129:17: error: static assertion expression is not an integral constant expression
# |   129 |   static_assert(test_to_string<64>());
# |       |                 ^~~~~~~~~~~~~~~~~~~~
# | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/build/generic-hardened-mode/include/c++/v1/string:1164:10: note: constexpr evaluation hit maximum step limit; possible infinite loop?
# |  1164 |         {return __is_long() ? __get_long_size() : __get_short_size();}
# |       |          ^
# | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/build/generic-hardened-mode/include/c++/v1/string:1205:50: note: in call to 'this->size()'
# |  1205 |     _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), "string index out of bounds");
# |       |                                                  ^
# | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:38:20: note: in call to 's.operator[](42)'
# |    38 |             assert(s[b.size() - 1 - i] == one);
# |       |                    ^
# | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:98:13: note: in call to 'check_equal(s, v, 48, 49)'
# |    98 |             check_equal(s, v, '0', '1');
# |       |             ^
# | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-bd9c7138da7d-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/template.bitset/bitset.members/to_string.pass.cpp:129:17: note: in call to 'test_to_string()'
# |   129 |   static_assert(test_to_string<64>());
```

https://github.com/llvm/llvm-project/pull/66576


More information about the cfe-commits mailing list