Skip to content

Avoid initializer-string warning for the digits array#495

Open
nickva wants to merge 1 commit intobellard:masterfrom
nickva:fix-initializer-string-warning
Open

Avoid initializer-string warning for the digits array#495
nickva wants to merge 1 commit intobellard:masterfrom
nickva:fix-initializer-string-warning

Conversation

@nickva
Copy link
Copy Markdown
Contributor

@nickva nickva commented Mar 24, 2026

Some newer compilers emit this warning:

warning: initializer-string for character array is too long, array size is 36 
     but initializer has size 37 (including the null terminating character);
     did you mean to use the 'nonstring' attribute? [-Wunterminated-string-initialization]
 12146 | static char const digits[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
       |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To avoid the warning initialize the array as individual characters

Some newer compilers emit this warning:

```
warning: initializer-string for character array is too long, array size is 36
     but initializer has size 37 (including the null terminating character);
     did you mean to use the 'nonstring' attribute? [-Wunterminated-string-initialization]
 12146 | static char const digits[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
       |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

To avoid the warning initialize the array as individual characters
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.

1 participant