public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30783]  New: "character(*), value" produces SEGV at runtime
@ 2007-02-13  8:55 burnus at gcc dot gnu dot org
  2007-02-13  9:54 ` [Bug fortran/30783] " dominiq at lps dot ens dot fr
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-13  8:55 UTC (permalink / raw)
  To: gcc-bugs

The combination of the VALUE attribute with CHARACTER(*) gives segmentation
faults (SIGSEGV, SIGBUS). Without VALUE or with "CHARACTER(10), VALUE" it
works.

------ Test case ------------
program x
  implicit none
  character(10) :: c
  c = 'Main'
  print *, c
  call foo(c)
  print *, c
contains
  subroutine foo(a)
    character(*) :: a
    value :: a
    print *, 'Foo: ',a
    a = 'Hello'
    print *, 'Foo: ',a
  end subroutine foo
end program x
------ Test case ------------

I don't know whether it can be made to work, if not, one could do something
like   Chris does in the Fortran-Experiments branch (except of only disallowing
the length "*"):

      /* Character strings are a hassle because they may be length 1,
         or assumed length (*), etc., so we need to find a way to
         prevent by-value dummy char args from being anything but
         length 1 constants, because C will only pass a pointer in
         any other cases.  However, we can't help the following with the
         logic being used below:
         character(c_char), value :: my_char
         character(kind=c_char, len=1), value :: my_char_str
         hope the user does the right thing.  */
     if (sym->attr.value == 1 && sym->ts.type == BT_CHARACTER)
       /* if we can't verify the length of 1...error */
       if (sym->ts.cl == NULL || sym->ts.cl->length == NULL
           || (sym->ts.cl->length->value.character.length != 1))
         gfc_error_now ("VALUE attribute at %L cannot be used "
                        "for character strings", &(sym->declared_at));


-- 
           Summary: "character(*), value" produces SEGV at runtime
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/30783] "character(*), value" produces SEGV at runtime
  2007-02-13  8:55 [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime burnus at gcc dot gnu dot org
@ 2007-02-13  9:54 ` dominiq at lps dot ens dot fr
  2007-02-13 18:19 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-02-13  9:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dominiq at lps dot ens dot fr  2007-02-13 09:54 -------
Compiling the test with xlf gives:

"pr30783.f90", line 6.12: 1513-061 (S) Actual argument attributes do not match
those specified by an accessible explicit interface.
"pr30783.f90", line 11.14: 1516-181 (S) Objects of type CHARACTER with length
greater than 1, with run time length, or with assumed length must not be
declared with the VALUE attribute.

and with g95

Error: Character dummy variable 'a' at (1) with the VALUE attribute must have a
constant length


-- 


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


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

* [Bug fortran/30783] "character(*), value" produces SEGV at runtime
  2007-02-13  8:55 [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime burnus at gcc dot gnu dot org
  2007-02-13  9:54 ` [Bug fortran/30783] " dominiq at lps dot ens dot fr
@ 2007-02-13 18:19 ` burnus at gcc dot gnu dot org
  2007-02-13 18:30 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-13 18:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-02-13 18:19 -------
>From the Fortran 2003 standard:
--------------
C528 (R501) If the VALUE attribute is specified, the length type parameter
values shall be omitted or specified by initialization expressions.
--------------

Which rules out deferred type parameters such as "*" or ":".

However, I fail to see anything which rules out "(10)" even though also sunf95
and NAG f95 claim that anything but nothing or "(1)" is wrong.

ifort and g95 allow "(10)" but crash or at least access uninitialized memory.

And as said: gfortran allows "(10)" and it works properly.


-- 


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


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

* [Bug fortran/30783] "character(*), value" produces SEGV at runtime
  2007-02-13  8:55 [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime burnus at gcc dot gnu dot org
  2007-02-13  9:54 ` [Bug fortran/30783] " dominiq at lps dot ens dot fr
  2007-02-13 18:19 ` burnus at gcc dot gnu dot org
@ 2007-02-13 18:30 ` burnus at gcc dot gnu dot org
  2007-02-14  8:55 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-13 18:30 UTC (permalink / raw)
  To: gcc-bugs



-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-02-13 18:30:14
               date|                            |


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


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

* [Bug fortran/30783] "character(*), value" produces SEGV at runtime
  2007-02-13  8:55 [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-02-13 18:30 ` burnus at gcc dot gnu dot org
@ 2007-02-14  8:55 ` patchapp at dberlin dot org
  2007-02-20  9:17 ` burnus at gcc dot gnu dot org
  2007-02-20  9:45 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: patchapp at dberlin dot org @ 2007-02-14  8:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from patchapp at dberlin dot org  2007-02-14 08:55 -------
Subject: Bug number PR30783

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01226.html


-- 


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


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

* [Bug fortran/30783] "character(*), value" produces SEGV at runtime
  2007-02-13  8:55 [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-02-14  8:55 ` patchapp at dberlin dot org
@ 2007-02-20  9:17 ` burnus at gcc dot gnu dot org
  2007-02-20  9:45 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-20  9:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2007-02-20 09:17 -------
Subject: Bug 30783

Author: burnus
Date: Tue Feb 20 09:16:58 2007
New Revision: 122156

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122156
Log:
2007-02-20  Tobias Burnus  <burnus@net-b.de>

       PR fortran/30783
       * resolve.c (resolve_symbol): Add character dummy VALUE check.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c


-- 


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


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

* [Bug fortran/30783] "character(*), value" produces SEGV at runtime
  2007-02-13  8:55 [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-02-20  9:17 ` burnus at gcc dot gnu dot org
@ 2007-02-20  9:45 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-20  9:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2007-02-20 09:45 -------
Fixed in 4.3 (not present in 4.2).


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2007-02-20  9:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-13  8:55 [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime burnus at gcc dot gnu dot org
2007-02-13  9:54 ` [Bug fortran/30783] " dominiq at lps dot ens dot fr
2007-02-13 18:19 ` burnus at gcc dot gnu dot org
2007-02-13 18:30 ` burnus at gcc dot gnu dot org
2007-02-14  8:55 ` patchapp at dberlin dot org
2007-02-20  9:17 ` burnus at gcc dot gnu dot org
2007-02-20  9:45 ` burnus at gcc dot gnu dot 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).