Skip to content

Fix build warning - #986

Open
ltrzesniewski wants to merge 1 commit into
PCRE2Project:mainfrom
ltrzesniewski:buffer-size-fix
Open

ltrzesniewski wants to merge 1 commit into
PCRE2Project:mainfrom
ltrzesniewski:buffer-size-fix

Conversation

@ltrzesniewski

Copy link
Copy Markdown
Contributor

I'm not 100% sure about this one, but I noticed GCC 15.2.0 complains when building in an Alpine image (with musl), while GCC 13.3.0 is fine with that (with glibc).

Historically, UTF-8 allowed up to 6 bytes per code point, but the spec later limited that to 4. Using 6 bytes in this buffer fixes the warning.

I know PCRE2 requires valid UTF-8 and performs a validity check beforehand, but better be safe than sorry, right? :)

@NWilson

NWilson commented Sep 13, 2026

Copy link
Copy Markdown
Member

Ooh, this is interesting. That is some very fine reasoning it's done there.

Our GETUTF8 macro does read up to 6 bytes, so purely based on local reasoning, it's absolutely right that the character value can be larger than 0x10FFFF (locally). And hence char_othercase can output a uint32_t value that (locally) requires the full 6 byte of buffer space.

I don't think we have a problem in practice: as you say, the input is pre-validated, so we know that in fact the character cannot be larger than 0x10FFFF.

I don't have strong opinion on the best way of silencing the warning, or asserting, or whatever. This PR is certainly a reasonable idea.

Ultimately GETUTF8 has unreachable branches confusing GCC, and it could have the 5/6 byte forms trimmed out. That would also remove the issue.

@NWilson NWilson added the JIT Relating to the JIT feature label Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JIT Relating to the JIT feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants