[Bug fortran/48351] [OOP] Realloc on assignment fails if parent component is CLASS

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 30 08:39:00 GMT 2011


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

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

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-03-30 08:32:55 UTC ---
(In reply to comment #1)
> The reason is that the CLASS wrapper does not set:
> (gdb) p expr->symtree->n.sym->ts.u.derived->attr.alloc_comp

If I set that variable manually in the debugger, the generated code contains
(re)assignment calls, but the program crashes nevertheless :-(


[I do not want to rule out issues with my local tree, which has some scalarizer
coarray patches, though they should not affect this result.]


Admittedly, I also do not understand the dump (with explicit size "4" to make
the dump easier to read):

        if ((real(kind=8)[0:] * restrict) this->_data->u.data == 0B) goto L.1;

        L.1:;
        D.1608 = MAX_EXPR <(this->_data->u.dim[0].ubound -
this->_data->u.dim[0].lbound) + 1, 0>;

[...]
        if ((real(kind=8)[0:] * restrict) this->_data->u.data == 0B)
          {
            this->_data->u.data = (void * restrict) __builtin_malloc (32);


What's D.1608 for? If u.data == NULL, the bounds should not be looked at --
admittedly, this information is only used later in the else branch of the "if"
shown above.

Other than that, the dump looks OK as far as I could see.

Valgrind claims - before the crash - "Invalid write of size 8" in the
assignment line of "make". (Write 8 could be a pointer or an array index.) The
actual crash is in the same line - and valgrind shows: "Access not within
mapped region at address 0x0", which means something like "(NULL).value" or
"(NULL)->value" access.



More information about the Gcc-bugs mailing list