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

--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to federico from comment #3)
> Right: here is a version where the object is initialized: 
> 
> https://godbolt.org/z/o566cPG8P
> 
> I also see that for the versions that compile (e.g., 11.1.0), there's a
> weird SEGFAULT error at this line: 
> 
> 
>     elemental logical function isa(this,i)
>        class(t), intent(in) :: this
>        integer, intent(in) :: i
>        integer :: n
>        n = merge(size(this%iloc),0,allocated(this%iloc))
>        if (i>0 .and. i<=n) then ! Segmentation fault here 
>           isa = this%iloc(i)>0
>        else
>           isa = .false.
>        endif  
>     end function isa
> 
> So it at least compiles, but apparently the bug is hidden somewhere else?

Well, the following might be the reason for failure:

       ilocs = pack(this%iloc(IDs),this%is_active(ilocs))

Here ilocs is not allocated, it is the function result.

Also Intel does not like it.

Replacing these lines with

       ilocs = pack(this%iloc(IDs),this%is_active(IDs))

makes the code run successfully for gcc versions listed under "known to work".

User error?

Reply via email to