Repository navigation
Count the characters, not the bytes, of a string literal initializer of an array new-expression in constant evaluation [GH #501] - #502
Conversation
…of an array new-expression in constant evaluation [GH #501]
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
AcknowlEDG review results updated for
CI success. |
Fixes #501.
During constant evaluation, the check that the number of elements allocated by an array new-expression suffices for its initializer took the length of a string literal initializer in bytes, rather than in characters. So, for a character type wider than one byte (e.g.,
wchar_t,char16_t, orchar32_t), an array large enough for the literal could be diagnosed as too small:The interpreter now divides the byte length by the size of the element type. The new tests cover
wchar_t,char16_t,char32_t, andchar8_t(regressions/gh-501), and confirm that a too-short array is still diagnosed (regressions/gh-501-neg).Summary by CodeRabbit
wchar_t,char8_t,char16_t, andchar32_tstring initializers, including cases where the allocated array is too small.