-
Notifications
You must be signed in to change notification settings - Fork 182
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
A runtime error occurs when assigning a variable of bitset_large
#726
Comments
Thank you.
It seems to be indeed the case. Intel ifort compilers do not seem to have this issue (see #727 ). Therefore, is it a compiler issue or a code issue? @milancurcic @awvwgk any idea? Note: since the derived type |
Thank you for working on reproducing this issue on your Linux machine. I don't know why the intel compiler does not reproduce the issue, but I suspect it is the compiler implementation. The gfortran's behavior may be compiler-dependent, but the code does not seem to violate the Fortran standard, so I would like to fix the assignment procedure for |
I'm not sure... When assigning an object to itself, the routine |
Thank you, @PierUgit, for comment on argument aliasing. I asked for help in Fortran Discourse because the issue was beyond my knowledge and may provide important insights for other Fortran users. |
To make the program conform, my read is you can change the assignment to explicitly reference an expression on the right-hand side: bitsetl(0) = ( bitsetl(0) ) And then file another report with This might satisfy the principle of least change for stdlib while enhancing that one processor if the support request gets worked on promptly. |
Thank you, @FortranFan, for the information from a different perspective from what we have been considering. The modification you suggested would require changes in several places in the sorting procedures for fixing the issue occurring only with the |
As the sorting procedures are most likely used for sorting arrays of integers or reals, I am not in favour of such a solution, as it could impact the performances of these procedures. But it questions the versatility of the sorting procedures too. |
Description
A runtime error occurs when assigning
bitset_large
type variables to oneself. Such a situation arises when extendingstdlib_sorting
to support sorting arrays ofbitset_large
type. The error message isFortran runtime error: Allocatable argument 'set2' is not allocated
.set2
is defined in the procedureassign_large
as the variable on the right-hand side of the assignment operator.This phenomenon can be reproduced with the following code.
The details are described in the Additional Information section. For simplicity, gfortran 11.2.0 was used as the compiler, and
-Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace
was used as the compile option. The options are specified in the actions defined in ci_windows.yml.Expected Behaviour
I expected the
bitsetl(0)
value to remain unchanged in the above code.Version of stdlib
2b7280b
Platform and Architecture
Windows 10 22H2 64bit, gfortran 11.2 bundled with quickstart Fortran on Windows
Additional Information
Here I describe how I identified the issue.
The directory structure was
Cloned stdlib and built it with compiler options used in the actions defined in ci_windows.yml.
Then install it in the
bitset_test
directory.In the
bitset_test
directory, I compiledmain.f90
using gfortran. Themain.f90
is shown the Description section.>gfortran main.f90 -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace -Iinclude\fortran_stdlib\GNU-11.2.0 -Llib -lfortran_stdlib
When running the generated executable file
a.exe
, a runtime error occurred, and the error message was displayed:The line specified by the message is in the procedure
assign_large
that performs the assignment operation ofbitset_large
type.The error may be due to the deallocation of the component
blocks
ofset2
caused by theintent(out)
attribute forset1
sinceset1
andset2
are the same variable.I changed the attribute of
set1
, the argument specifying the left-hand side of the assignment operator, fromout
toinout
and re-run the executable again, followed by the above procedures. An error still occurred, but the message has changed toAttempting to allocate already allocated variable 'set1'
.Since the same variables are specified on both sides of the assignment operator, it is natural that the variable on the left side is already allocated. But no error should occur in this situation.
The solutions I am trying to are:
set1
fromout
toinout
and use the automatic array allocation for the componentblocks
:The text was updated successfully, but these errors were encountered: