You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The option -i is supposed to generate an array length variable as an int. The C standard only guarantees 16 bits for an int. An array greater than 2^16 entries should cause issues.
Expected behaviour
Generate a type that can hold the maximum array size for a platform, e.g. size_t
Version of Vim
I read the source code on the repo
Environment
Irrelevant
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered:
From what I understand, the PR was reverted because some projects include the standard headers that have size_t after including the generated code from xxd -i, or don't include them at all, although I still don't know any examples of such projects.
So a solution needs to be implemented when xxd/vim decides to make a breaking change, the header needs to be included, or there needs to be fully dynamic type generation.
I'm not sure if there are examples where using dynamic type generation can still fail, but I suppose this depends on what calculations are done with the array size.
I'm sure it's possible to come up with pathological examples like https://mohitmv.github.io/blog/Shocking-Undefined-Behaviour-In-Action/ example1, but those might not necessarily be things that a normal person would do with an array size variable. It might happen when a type is not promoted appropriately, like if printing the size of an array in bytes whose individual entries are very large, assuming someone doesn't use sizeof() for this.
Implementing dynamic type generation would ideally also fix #13887 .
Steps to reproduce
The option -i is supposed to generate an array length variable as an int. The C standard only guarantees 16 bits for an int. An array greater than 2^16 entries should cause issues.
Expected behaviour
Generate a type that can hold the maximum array size for a platform, e.g. size_t
Version of Vim
I read the source code on the repo
Environment
Irrelevant
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: