[Bug fortran/85938] New: Spurious assert failure for matmul with reshaped array

stephan.kramer at imperial dot ac.uk gcc-bugzilla@gcc.gnu.org
Sat May 26 18:57:00 GMT 2018


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

            Bug ID: 85938
           Summary: Spurious assert failure for matmul with reshaped array
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stephan.kramer at imperial dot ac.uk
  Target Milestone: ---

The following program

program foo

  real, dimension(9) :: A
  real, dimension(3) :: b
  integer :: n = 3

  A = 1.0
  b = 1.0
  print *, matmul(reshape(A, (/ n, n /)), b)

end program

compiled with, or without optimisation, produces the following runtime
assertion failure in libgfortran:

$ gfortran test.f90 
$ ./a.out 
a.out: ../../../src/libgfortran/generated/matmul_r4.c:651: matmul_r4_avx2:
Assertion `GFC_DESCRIPTOR_RANK (a) == 2 || GFC_DESCRIPTOR_RANK (b) == 2'
failed.

Program received signal SIGABRT: Process abort signal.

I also tried -fno-frontend-optimize to no avail.
Backtrace in gdb:

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6dfc231 in __GI_abort () at abort.c:79
#2  0x00007ffff6df39da in __assert_fail_base (fmt=0x7ffff6f46d48 "%s%s%s:%u:
%s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x7ffff7ba9ec8 "GFC_DESCRIPTOR_RANK (a) == 2 ||
GFC_DESCRIPTOR_RANK (b) == 2", 
    file=file@entry=0x7ffff7baa300
"../../../src/libgfortran/generated/matmul_r4.c", line=line@entry=651, 
    function=function@entry=0x7ffff7baa368 "matmul_r4_avx2") at assert.c:92
#3  0x00007ffff6df3a52 in __GI___assert_fail (assertion=0x7ffff7ba9ec8
"GFC_DESCRIPTOR_RANK (a) == 2 || GFC_DESCRIPTOR_RANK (b) == 2", 
    file=0x7ffff7baa300 "../../../src/libgfortran/generated/matmul_r4.c",
line=651, function=0x7ffff7baa368 "matmul_r4_avx2") at assert.c:101
#4  0x00007ffff7a5c9a3 in ?? () from /usr/lib/x86_64-linux-gnu/libgfortran.so.5
#5  0x0000555555554c32 in foo () at test.f90:8
#6  0x0000555555554cf0 in main (argc=1, argv=0x7fffffffe38c) at test.f90:10
#7  0x00007ffff6de7a87 in __libc_start_main (main=0x555555554cba <main>,
argc=1, argv=0x7fffffffe088, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffe078) at
../csu/libc-start.c:310
#8  0x000055555555482a in _start ()

This is based on source and debugging symbols for Debian gcc-8 8.1.0-3


More information about the Gcc-bugs mailing list