public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104520] New: Unexpected behavior with STORAGE_SIZE intrinsic with a dummy argument that is unlimited polymorphic
@ 2022-02-13 17:47 fortranfan at outlook dot com
0 siblings, 0 replies; only message in thread
From: fortranfan at outlook dot com @ 2022-02-13 17:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104520
Bug ID: 104520
Summary: Unexpected behavior with STORAGE_SIZE intrinsic with a
dummy argument that is unlimited polymorphic
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: fortranfan at outlook dot com
Target Milestone: ---
Consider the following:
--- begin code ---
module m
use, intrinsic :: iso_fortran_env, only : character_storage_size
contains
subroutine sub( a )
class(*), intent(in) :: a
print *, "storage_size(s) = ", storage_size(a)
select type ( a )
type is ( character(len=*) )
print *, "expected is ", len(a)*character_storage_size
end select
end subroutine
end module
use m
character(len=2) :: s
call sub( s )
end
--- end code ---
And the program behavior using gfortran:
--- begin console output ---
C:\temp>gfortran -Wall y.f90 -o y.exe
C:\temp>y.exe
storage_size(s) = 8
expected is 16
C:\temp>
--- end output ---
On the other hand, consider the following:
--- begin code ---
character(len=2) :: s
print *, storage_size(s)
end
--- end code ---
The program behavior is
--- begin output ---
C:\temp>gfortran -Wall y.f90 -o y.exe
C:\temp>y.exe
16
C:\temp>
--- end output ---
I failed to find anything in the Fortran standard that supports the above shown
program behavior. Can the first case with the unlimited polymorphic dummy be
expected to the same as the second, meaning the storage size of the object get
determined as 16 bits?
Thank you,
Vipul Parekh
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-13 17:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-13 17:47 [Bug fortran/104520] New: Unexpected behavior with STORAGE_SIZE intrinsic with a dummy argument that is unlimited polymorphic fortranfan at outlook dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).