Skip to content

Conversation

@iluuu1994
Copy link
Member

@iluuu1994 iluuu1994 commented Mar 5, 2023

warning: array subscript -65 is below array bounds of ‘const char[26]‘ [-Warray-bounds]

Errors like these sometimes only appear with optimizations when inlining/loop unrolling.

warning: array subscript -65 is below array bounds of ‘const char[26]‘
[-Warray-bounds]

Errors like these sometimes only appear with optimizations when inlining/look
unrolling.
Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this. It looks good. and adding an assert is definitely a good idea in any case :)



/* Note: these macros require an uppercase letter input! */
#define ENCODE(c) (isalpha(c) ? _codes[((c) - 'A')] : 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the comment saying "macros" is strictly speaking incorrect right now, since we have a function too.

static zend_always_inline char encode(char c) {
if (isalpha(c)) {
ZEND_ASSERT(c >= 'A' && c <= 'Z');
return _codes[((c) - 'A')];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also slightly stupid codestyle nit: we don't need the parens here anymore, but I don't really care as it doesn't matter anyway...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, true 🙂👍

@iluuu1994 iluuu1994 closed this in 5904952 Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants