Skip to content

Fix compilation error with GCC 15 #1045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged

Fix compilation error with GCC 15 #1045

merged 1 commit into from
May 2, 2025

Conversation

saghul
Copy link
Contributor

@saghul saghul commented May 1, 2025

quickjs.c:11727:32: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (37 chars into 36 available) [-Werror=unterminated-string-initialization]
11727 | static char const digits[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@saghul saghul force-pushed the fix-gcc15-error branch from cd254eb to 629e39d Compare May 1, 2025 22:36
Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM although I have a mild preference for writing it out as a char array so no compiler-specific annotations are necessary.

(It's what I did in 6e43400 but apparently I overlooked this one.)

cutils.c Outdated
@@ -596,7 +596,7 @@ size_t utf8_encode_buf16(char *dest, size_t dest_len, const uint16_t *src, size_
*/

/* 2 <= base <= 36 */
char const digits36[36] = {
char const digits36[36] JS_NONSTRING_ATTR = {
Copy link
Contributor

Choose a reason for hiding this comment

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

The attribute isn't necessary here, right?

@saghul
Copy link
Contributor Author

saghul commented May 2, 2025

Oh I see. That does look better. I'll align it to match your change.

```
quickjs.c:11727:32: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (37 chars into 36 available) [-Werror=unterminated-string-initialization]
11727 | static char const digits[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
@saghul saghul force-pushed the fix-gcc15-error branch from 629e39d to 296e245 Compare May 2, 2025 10:53
@saghul saghul merged commit b1500a2 into master May 2, 2025
127 checks passed
@saghul saghul deleted the fix-gcc15-error branch May 2, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants