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

Missing validation for pointer to pointer - alias/reference to ref-assignments #1347

Open
mhasel opened this issue Oct 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mhasel
Copy link
Member

mhasel commented Oct 23, 2024

When initializing an alias or reference to variable, we only check for the inner type, but not if the actual indirection-level matches the declaration.

FUNCTION main
VAR
    s1: REF_TO LINT;    
    s2 AT s1 : LINT;
    s3 : REFERENCE TO LINT REF= s1;
END_VAR
END_FUNCTION

Here, s2 and s3 should be REF_TO LINT but are declared as LINT. This leads to incorrect IR:

error[E071]: /tmp/.tmptgv8eP/target/demo.st.ll:12:9: error: stored value and pointer type do not match
  store i64** %s1, i64** %s2, align 8

While it seems like LLVM fixes this when compiling to an executable (no segfaults when assigning values, printf prints the expected values), we should still add a validation to check if the pointer-depth matches the declaration.

@mhasel mhasel added the bug Something isn't working label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant