public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56305] New: passing array of character with len>1 to c_loc
@ 2013-02-13 11:24 valeryweber at hotmail dot com
  2013-02-13 12:20 ` [Bug fortran/56305] " burnus at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: valeryweber at hotmail dot com @ 2013-02-13 11:24 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56305

             Bug #: 56305
           Summary: passing array of character with len>1 to c_loc
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: valeryweber@hotmail.com


Dear All
The following code compiles, but shouldnt it be rejected? 
V

program aaa
  use, intrinsic :: iso_c_binding
  type(c_ptr) :: p
  character(len=2),dimension(1), target :: c
  p=c_loc(c(1))
end program aaa


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/56305] passing array of character with len>1 to c_loc
  2013-02-13 11:24 [Bug fortran/56305] New: passing array of character with len>1 to c_loc valeryweber at hotmail dot com
@ 2013-02-13 12:20 ` burnus at gcc dot gnu.org
  2013-03-20 14:42 ` burnus at gcc dot gnu.org
  2013-03-21 21:43 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-02-13 12:20 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56305

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-02-13 12:19:39 UTC ---
> The following code compiles, but shouldnt it be rejected?

It seems to be invalid Fortran 2003 but valid Fortran 2008 (w/ and w/o
TS29113). The gfortran's diagnostic handling for C_LOC still needs some changes
for -std=f2003, -std=f2008, -std=f2008ts (rejecting too much, some diagnostic
missing for -std=f2003).


Fortran 2003 has ("15.1.2.5 C LOC (X)"):
"Argument. X shall either
 (1) have interoperable type and type parameters and be [...]
 (2) be a nonpolymorphic scalar, have no length type parameters, and be [...]"

A type parameter of len=2 is not valid and also "c" is not a scalar – Thus, it
seems to be invalid. 


However, it seems to be valid with Fortran 2008 ("15.2.3.6 C LOC (X)"); note
the change "type parameter" to "kind type parameter"

"Argument. X shall have either the POINTER or TARGET attribute. It shall not be
a coindexed object. It shall either be a variable with interoperable type and
kind type parameters, or be a scalar, nonpolymorphic variable with no length
type parameters. If it is allocatable, it shall be allocated. If it is a
pointer, it shall be associated. If it is an array, it shall be contiguous and
have nonzero size. It shall not be a zero-length string."



TS 29113 changes the latter as follows:

"{In 15.2.3.6 C_LOC(X), paragraph 3}
 Delete 'scalar,'."


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/56305] passing array of character with len>1 to c_loc
  2013-02-13 11:24 [Bug fortran/56305] New: passing array of character with len>1 to c_loc valeryweber at hotmail dot com
  2013-02-13 12:20 ` [Bug fortran/56305] " burnus at gcc dot gnu.org
@ 2013-03-20 14:42 ` burnus at gcc dot gnu.org
  2013-03-21 21:43 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-20 14:42 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56305

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-20 14:42:19 UTC ---
(In reply to comment #1)
> It seems to be invalid Fortran 2003 but valid Fortran 2008

> Fortran 2003 has ("15.1.2.5 C LOC (X)"):
> "Argument. X shall either
>  (1) have interoperable type and type parameters and be [...]

As this change is already in the Technical Corrigendum 5 to Fortran 2003, it is
also valid in Fortran 2003. See PR39288.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/56305] passing array of character with len>1 to c_loc
  2013-02-13 11:24 [Bug fortran/56305] New: passing array of character with len>1 to c_loc valeryweber at hotmail dot com
  2013-02-13 12:20 ` [Bug fortran/56305] " burnus at gcc dot gnu.org
  2013-03-20 14:42 ` burnus at gcc dot gnu.org
@ 2013-03-21 21:43 ` burnus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-21 21:43 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56305

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-21 21:43:42 UTC ---
Based on my last comment, closed as INVALID.

In any case, thanks for the comment - even if it turned out to be not a bug
(because the standard changed ;-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-21 21:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-13 11:24 [Bug fortran/56305] New: passing array of character with len>1 to c_loc valeryweber at hotmail dot com
2013-02-13 12:20 ` [Bug fortran/56305] " burnus at gcc dot gnu.org
2013-03-20 14:42 ` burnus at gcc dot gnu.org
2013-03-21 21:43 ` burnus at gcc dot gnu.org

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).