https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117264

--- Comment #7 from Vladimir Terzi <vterzi1996 at gmail dot com> ---
(In reply to anlauf from comment #5)
> Please show the exact failing code.

I noticed that my comment is somewhat misleading, so I will clarify.

(In reply to Vladimir Terzi from comment #4)
> That's strange... For some reason, the behavior is different on Rocky Linux 
> 8.7
> (same architecture: x86_64).

I meant here that the function with `result` (as the *only* change in the
failing code) also fails on Rocky Linux 8.7 (and Ubuntu 18.04 with gfortran
13.1.0), i.e. with this function:
```
function f() result(r)
  class(t), allocatable :: r
  r=tt()
end
```

(In reply to Vladimir Terzi from comment #4)
> Yes, I'm using the explicit allocation in my code with `source` (and a
> constructor with arguments).

I meant here that the code only works with explicit allocation for *both*
allocatables:
* `allocate(o,source=f())` instead of `o=f()` and
* `allocate(tt::f)` instead of `f=tt()`.
The second one can be omitted, if `result` is used, but the first assignment
is, apparently, the main problem.

(In reply to kargls from comment #6)
> Agree with Harald, we need to see the actual code and error.

The actual code is in my first post. The error is as follows (even with `-O0
-g` flags):
```
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7f143c5e3b7f in ???
#1  0x0 in ???
Segmentation fault (core dumped)
```

Reply via email to