https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97818
Bug ID: 97818 Summary: PDT Parameterized Derived Type fails with SIGABRT at -O1 Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: adamjermyn at gmail dot com Target Milestone: --- Created attachment 49558 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49558&action=edit Minimal broken example. Compile with -O1. Should result in SIGABRT. Hello, I encountered an error (SIGABRT on macOS) using parameterized derived types in Fortran with gfortran v10.2.0. The error only appears at -O1 or above. I've attached a minimal broken example. An example of the error message is: --- a.out(64288,0x116e325c0) malloc: *** error for object 0x7ffee429c8e8: pointer being freed was not allocated a.out(64288,0x116e325c0) malloc: *** set a breakpoint in malloc_error_break to debug Program received signal SIGABRT: Process abort signal. --- The derived type supports arithmetic operations (+-/*), but for the minimal example I've stripped this down to just addition, and removed the actual addition logic (just leaving empty functions). >From some testing, the error only appears when there are common sub-expressions. So for instance in the attached example I've written z = (x + 2.0) + ((x + 2.0) + 1.0) which fails. When I manually break the expression up into smaller pieces that don't share common sub-expressions (as below) it works: y = x + 2.0 z = y + (y + 1.0) I've tested ~10 examples like this and only ones where common sub-expressions occur in a single function produce this problem. I'm happy to provide a version of this example that has the arithmetic logic filled in if that would be helpful. If this is not a compiler problem and I'm doing something wrong I would greatly appreciate being pointed in the right direction. Many thanks, Adam