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

Proposal to fix the procedure move for string_type #736

Merged
merged 7 commits into from Sep 4, 2023

Conversation

jvdp1
Copy link
Member

@jvdp1 jvdp1 commented Sep 3, 2023

Issue (see #731 and #735 for more detail): seg fault occurs when the input and output string_type variable is the same in move:

call move( from, from)

@band-a-prend @nkevy @awvwgk Would this proposition work for you? Could you test it with GCC 13, please?

Fixes #731 and #735

@jvdp1 jvdp1 changed the title Proposal to fix the function move for string_type Proposal to fix the procedure move for string_type Sep 3, 2023
@nkevy
Copy link

nkevy commented Sep 3, 2023

@jvdp1 yes your pull request fixed test string_intrisic
Start 42: string_intrinsic 42/57 Test #42: string_intrinsic ................. Passed 0.11 sec
cmake version 3.27.4
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.6.0
MacOS 11.7.4

Kind Regards,
@nkevy

@band-a-prend
Copy link

@jvdp1
I'm not sure why it's required this way

if(from%raw .eq. to%raw)then
         deallocate(from%raw)

Does the initial (allocated) string str will be dealocated now if try to do move(str, str)?
Or the from%raw or to%raw already called additional allocation?

But with GCC 13 all tests are passed now with proposed patches.

@jvdp1
Copy link
Member Author

jvdp1 commented Sep 4, 2023 via email

@band-a-prend
Copy link

@jvdp1
If it works as expected then it's ok. I'm just half-asleep :)
Great thanks for fix!

src/stdlib_string_type.fypp Outdated Show resolved Hide resolved
src/stdlib_string_type.fypp Outdated Show resolved Hide resolved
jvdp1 and others added 4 commits September 4, 2023 07:43
Co-authored-by: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com>
Co-authored-by: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com>
@jvdp1
Copy link
Member Author

jvdp1 commented Sep 4, 2023

@awvwgk I pushed your changes, but then the test "move: test case 8" failed.

So, what should be the value of from after call move(from, from)? Should it be deallocated (as assumed previously), or should it contains the value of from?

@awvwgk
Copy link
Member

awvwgk commented Sep 4, 2023

This changes the behaviour from undefined to copying to self will be a no-op. We would need to update the test and the specs, but I think it makes more sense this way.

@jvdp1
Copy link
Member Author

jvdp1 commented Sep 4, 2023

This changes the behaviour from undefined to copying to self will be a no-op. We would need to update the test and the specs, but I think it makes more sense this way.

Ok. I modified both the tests and specs with the "new" behaviour. Could you @awvwgk have another check, please?

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.

Looks good to me now

@jvdp1 jvdp1 merged commit 82f35a5 into fortran-lang:master Sep 4, 2023
17 checks passed
@jvdp1 jvdp1 deleted the fix_string_intrinsic branch September 4, 2023 17:37
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.

Test: string_intrinsic (move) failed built with GCC 13.2
4 participants