Skip to content
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

Data type inconsitency #7

Open
Epitax opened this issue Jul 16, 2024 · 0 comments
Open

Data type inconsitency #7

Epitax opened this issue Jul 16, 2024 · 0 comments

Comments

@Epitax
Copy link

Epitax commented Jul 16, 2024

I have been refactoring your code to change the alphabet size.
To accomplish that, I have been differentiating between the types of variables that hold the index to the T[] array (the input string) and variables that hold the elements of the input string, like c=T[i].

In your code, the input string consists of byte sized elements, but my goal is to make the code easily changeable to handle wider elements and larger alphabet sizes.

In the process of this refactoring, I have encountered two inconsistent places in the code:

in sais.c: 660
if(sais_mainlcp(RA, SA, NULL, newfs, m, name, sizeof(sais_index_type), 0, 0) != 0) {...

and...

in sais.c:932
if(sais_main(RA, SA, newfs, m, name, sizeof(sais_index_type), 0) != 0) {...

The 1st parameter of the sais_main() and sais_mainlcp() functions is an address of the input string T.
However, the RA variable appears to hold an address of some element inside the Suffix Array (SA), as evidenced by the lines
in sais.c:926 and in sais.c653
RA = SA + m + newfs;

Also, the assignment in the followings lines suggests that the SA[ ] and RA[ ] arrays consist of elements of the same type:
in sais.c:656
in sais.c:929
RA[j--] = SA[i] - 1;

The Suffix Array SA[ ] holds indexes to the T[ ] array (the input string).
To accommodate e.g. a 1GB string, these indexes must be wide e.g. uint32_t, while the elements of the T[ ] array can be smaller, e.g.: uint8_t or uint16_t.

This type inconsistency generates the following compiler warning:
warning C4133: 'function sais_main()': incompatible types in 1st parameter - conversion from 'uint32_t *' to 'const uint16_t *'

Q: What is the RA[ ] array ? What does it hold ? What is its purpose ?
Q: How to solve this warning conceptually, ...without just ignoring it ?

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

No branches or pull requests

1 participant