This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/30783] New: "character(*), value" produces SEGV at runtime
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Feb 2007 08:55:02 -0000
- Subject: [Bug fortran/30783] New: "character(*), value" produces SEGV at runtime
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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