This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46408] [OOP] Segfault when running gfortran.dg/class_allocate_6.f03
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 2 Jan 2011 16:24:07 +0000
- Subject: [Bug fortran/46408] [OOP] Segfault when running gfortran.dg/class_allocate_6.f03
- Auto-submitted: auto-generated
- References: <bug-46408-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46408
--- Comment #5 from janus at gcc dot gnu.org 2011-01-02 16:24:00 UTC ---
(In reply to comment #4)
> x%a should get default-initialized to NULL via the memcpy call from
> x._vptr->_def_init. The memcpy itself is done alright, but apparently the
> _def_init variable is not properly initialized (is it?):
>
> static struct t2 __def_init_MAIN___t2 = {};
No, it's not. The problem is: __def_init_MAIN___t2 is declared as SAVE in
gfc_find_derived_vtab. Therefore it's allocatable components do not get
default-initialized to NULL. However, if we don't give it the SAVE attribute,
we get:
Error: Pointer initialization target at (1) must have the SAVE attribute
Because the def_init symbol is used as pointer init target for the vtab.
:(