public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/106500] ICE on function as an argument to c_sizeof()
Date: Fri, 05 Apr 2024 17:18:42 +0000	[thread overview]
Message-ID: <bug-106500-4-fM3g5edW99@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106500-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106500

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #4 from anlauf at gcc dot gnu.org ---
I've looked some time into this and have the impression we have the checks
wrong.

E.g. testcase gfortran.dg/c_sizeof_6.f90 expects as error:

gcc/testsuite/gfortran.dg/c_sizeof_6.f90:11:16:

   11 |    i = c_sizeof(str2(1:3)) ! { dg-error "must be an interoperable data"
}
      |                1
Error: 'x' argument of 'c_sizeof' intrinsic at (1) must be an interoperable
data entity: Only whole-arrays are interoperable


First, other compilers accept the code (Intel, NAG, Nvidia, flang), and also
the other testcases in the PR, plus they give the expected answers.

Second, the standard has:

! F2023:18.2.3.8  C_SIZEOF (X)
!
! X shall be a data entity with interoperable type and type parameters,
! and shall not be an assumed-size array, an assumed-rank array that
! is associated with an assumed-size array, an unallocated allocatable
! variable, or a pointer that is not associated.

and

! 3.41 data entity
! data object, result of the evaluation of an expression, or the
! result of the execution of a function reference

So, array sections could be interoperable, expressions, function results.

What is unclear to me: when is an expression interoperable?
Or rather when is it *not*?

(Note that the standard text has not essentially changed since F2008,
so we got this too strict from the beginning.)

  parent reply	other threads:[~2024-04-05 17:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 19:20 [Bug fortran/106500] New: ICE on invalid " kargl at gcc dot gnu.org
2022-08-01 19:47 ` [Bug fortran/106500] ICE on function as an " kargl at gcc dot gnu.org
2022-09-07 17:15 ` gscfq@t-online.de
2022-09-07 18:13 ` kargl at gcc dot gnu.org
2024-04-05 17:18 ` anlauf at gcc dot gnu.org [this message]
2024-04-08 19:03 ` anlauf at gcc dot gnu.org
2024-04-08 19:58 ` anlauf at gcc dot gnu.org
2024-04-10 17:04 ` cvs-commit at gcc dot gnu.org
2024-04-10 19:49 ` anlauf at gcc dot gnu.org

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-106500-4-fM3g5edW99@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: link
Be 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).