public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "fortranfan at outlook dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104520] New: Unexpected behavior with STORAGE_SIZE intrinsic with a dummy argument that is unlimited polymorphic Date: Sun, 13 Feb 2022 17:47:18 +0000 [thread overview] Message-ID: <bug-104520-4@http.gcc.gnu.org/bugzilla/> (raw) 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
reply other threads:[~2022-02-13 17:47 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-104520-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).