public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one
@ 2014-05-22 4:11 rouson at stanford dot edu
2014-05-23 15:18 ` [Bug fortran/61281] " dominiq at lps dot ens.fr
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: rouson at stanford dot edu @ 2014-05-22 4:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
Bug ID: 61281
Summary: Memory corruption on assigning a polymorphic variable
to a non-polymorphic one
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: rouson at stanford dot edu
The code below demonstrates a bug isolated from code from my collaborator Rob
Rosenberg of the Naval Research Laboratory. The code exhibits an apparent
memory corruption issue with gfortran 4.9 dated 20140416. Gfortran 4.8.2
rejects the code with the message below.
Damian
$ cat rob.f90
type employees
character(3) :: name="rob"
end type
type companies
type(employees) :: list
end type
type(companies) :: nrl
print *,nrl%list
call map
print *,nrl%list
contains
type (employees) function give_raise(e)
class(employees) :: e ! Switch to "type" to hide bug
give_raise=e
end function
subroutine map()
nrl%list=give_raise(nrl%list)
end subroutine
end
$ gfortran rob.f90
$ ./a.out
rob
8??
$ gfortran --version
GNU Fortran (MacPorts gcc49 4.9-20140416_0) 4.9.0 20140416 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
$ sudo port select --set gcc mp-gcc48
Selecting 'mp-gcc48' for 'gcc' succeeded. 'mp-gcc48' is now active.
$ gfortran rob.f90
rob.f90:14.15:
give_raise=e
1
Error: Can't convert CLASS(employees) to TYPE(employees) at (1)
localhost:Desktop rouson$ gfortran --version
GNU Fortran (MacPorts gcc48 4.8.2_0) 4.8.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61281] Memory corruption on assigning a polymorphic variable to a non-polymorphic one
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
@ 2014-05-23 15:18 ` dominiq at lps dot ens.fr
2014-05-23 20:48 ` rouson at stanford dot edu
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-23 15:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-05-23
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed. The error disappeared between r201266 (2013-07-26) and r201631
(2013-08-09).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61281] Memory corruption on assigning a polymorphic variable to a non-polymorphic one
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
2014-05-23 15:18 ` [Bug fortran/61281] " dominiq at lps dot ens.fr
@ 2014-05-23 20:48 ` rouson at stanford dot edu
2014-05-23 21:00 ` dominiq at lps dot ens.fr
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rouson at stanford dot edu @ 2014-05-23 20:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
--- Comment #2 from Damian Rouson <rouson at stanford dot edu> ---
I assume you're saying it disappeared and then reappeared and you're confirming
the problem exists on the current trunk. Correct?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61281] Memory corruption on assigning a polymorphic variable to a non-polymorphic one
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
2014-05-23 15:18 ` [Bug fortran/61281] " dominiq at lps dot ens.fr
2014-05-23 20:48 ` rouson at stanford dot edu
@ 2014-05-23 21:00 ` dominiq at lps dot ens.fr
2014-06-01 9:44 ` dominiq at lps dot ens.fr
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-23 21:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> I assume you're saying it disappeared and then reappeared and you're confirming
> the problem exists on the current trunk. Correct?
Sorry for the confusion. I meant
(1) I confirm the memory corruption after r201631,
(2) at least up to r201266, but not after r201630 (no archive in the gap),
gfortran used to emit the error
Error: Can't convert CLASS(employees) to TYPE(employees) at (1)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61281] Memory corruption on assigning a polymorphic variable to a non-polymorphic one
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
` (2 preceding siblings ...)
2014-05-23 21:00 ` dominiq at lps dot ens.fr
@ 2014-06-01 9:44 ` dominiq at lps dot ens.fr
2014-12-14 9:43 ` janus at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-06-01 9:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org,
| |janus at gcc dot gnu.org
--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Valgrind nor -fsanitize=address don't report any error.
The "memory corruption" is not limited to character variable and it occurs
already in map, i.e., give_raise(nrl%list) does not return 'rob'.
The error "Can't convert CLASS(employees) to TYPE(employees) at (1)" may have
been removed by r201328.
The original dump for type is:
map ()
{
nrl.list = give_raise (&nrl.list);
}
give_raise (struct employees & restrict e)
{
struct employees __result_give_raise;
{
struct employees employees.0;
(MEM[(c_char * {ref-all})&employees.0] = MEM[(c_char * {ref-all})"rob"];,
(void *) &employees.0.name;);
__result_give_raise = employees.0;
}
__result_give_raise = *e;
return __result_give_raise;
}
MAIN__ ()
{
static struct companies nrl = {.list={.name="rob"}};
static struct employees give_raise (struct employees & restrict);
static void map (void);
and with class it is:
__copy_MAIN___Employees (struct employees & restrict src, struct employees &
restrict dst)
{
*dst = *src;
}
map ()
{
{
struct __class_MAIN___Employees_t class.0;
class.0._vptr = (struct __vtype_MAIN___Employees * {ref-all})
&__vtab_MAIN___Employees;
class.0._data = &nrl.list;
nrl.list = give_raise (&class.0);
}
}
give_raise (struct __class_MAIN___Employees_t & restrict e)
{
struct employees __result_give_raise;
{
struct employees employees.1;
(MEM[(c_char * {ref-all})&employees.1] = MEM[(c_char * {ref-all})"rob"];,
(void *) &employees.1.name;);
__result_give_raise = employees.1;
}
__result_give_raise = VIEW_CONVERT_EXPR<struct employees>(*e);
return __result_give_raise;
}
MAIN__ ()
{
static struct __vtype_MAIN___Employees __vtab_MAIN___Employees =
{._hash=65382630, ._size=3, ._extends=0B,
._def_init=&__def_init_MAIN___Employees, ._copy=__copy_MAIN___Employees,
._final=0B};
static struct employees __def_init_MAIN___Employees = {.name="rob"};
static struct companies nrl = {.list={.name="rob"}};
static struct employees give_raise (struct __class_MAIN___Employees_t &
restrict);
static void map (void);
static void __copy_MAIN___Employees (struct employees & restrict, struct
employees & restrict);
...
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61281] Memory corruption on assigning a polymorphic variable to a non-polymorphic one
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
` (3 preceding siblings ...)
2014-06-01 9:44 ` dominiq at lps dot ens.fr
@ 2014-12-14 9:43 ` janus at gcc dot gnu.org
2014-12-14 10:24 ` dominiq at lps dot ens.fr
2014-12-14 12:13 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2014-12-14 9:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
--- Comment #5 from janus at gcc dot gnu.org ---
I can confirm the misbehavior with 4.9.1, but it seems that the problem is gone
on current trunk:
$ ./a.out
rob
rob
gcc version 5.0.0 20141213 (experimental) [trunk revision 218705] (GCC)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61281] Memory corruption on assigning a polymorphic variable to a non-polymorphic one
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
` (4 preceding siblings ...)
2014-12-14 9:43 ` janus at gcc dot gnu.org
@ 2014-12-14 10:24 ` dominiq at lps dot ens.fr
2014-12-14 12:13 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-12-14 10:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> I can confirm the misbehavior with 4.9.1, but it seems that the problem
> is gone on current trunk:
Confirmed. Likely fixed by r 216427 (pr63553).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61281] Memory corruption on assigning a polymorphic variable to a non-polymorphic one
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
` (5 preceding siblings ...)
2014-12-14 10:24 ` dominiq at lps dot ens.fr
@ 2014-12-14 12:13 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2014-12-14 12:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|NEW |RESOLVED
Known to work| |5.0
Resolution|--- |FIXED
Known to fail| |4.9.0
--- Comment #7 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #6)
> Confirmed. Likely fixed by r 216427 (pr63553).
Probably. Closing as fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-12-14 12:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22 4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
2014-05-23 15:18 ` [Bug fortran/61281] " dominiq at lps dot ens.fr
2014-05-23 20:48 ` rouson at stanford dot edu
2014-05-23 21:00 ` dominiq at lps dot ens.fr
2014-06-01 9:44 ` dominiq at lps dot ens.fr
2014-12-14 9:43 ` janus at gcc dot gnu.org
2014-12-14 10:24 ` dominiq at lps dot ens.fr
2014-12-14 12:13 ` janus 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).