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

Accept any length symbols' strings #1172

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

foxtran
Copy link
Contributor

@foxtran foxtran commented Feb 1, 2025

Noticed with xtb/vertical test, where length of symbols' strings equals one

Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

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

This would not work if you don't account for the variable character length in the allocation of the temporary array.

@foxtran
Copy link
Contributor Author

foxtran commented Feb 6, 2025

@awvwgk, why does not it work? character(len=:), allocatable :: str(:) can be also passed into character(len=*), allocatable :: str(:).

See an example here: https://godbolt.org/z/fc7nTKxnP

@awvwgk
Copy link
Member

awvwgk commented Feb 9, 2025

Because the allocation in the procedure still allocates using a fixed size, which would result in silent truncation. There is nothing against allocatable character arrays with allocatable length here (except spotty compiler support, as usual).

@foxtran foxtran force-pushed the patch-3 branch 2 times, most recently from 1ce07ea to 9ded4ae Compare February 10, 2025 23:36
@foxtran
Copy link
Contributor Author

foxtran commented Feb 11, 2025

@awvwgk, I have inserted a check that input string is no longer than symbolLength. Another way is to avoid known-length strings and use everywhere character(len=:), allocatable, dimension(:) strings arrays.

foxtran and others added 3 commits February 12, 2025 10:57
Noticed with xtb/vertical test, where length of symbols' strings equals one

Signed-off-by: Igor S. Gerasimov <[email protected]>
Signed-off-by: Igor S. Gerasimov <[email protected]>
Signed-off-by: Igor S. Gerasimov <[email protected]>
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.

3 participants