public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/99043] New: Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer
@ 2021-02-09 19:04 gustav.r.jansen at gmail dot com
  2021-02-10 10:30 ` [Bug fortran/99043] " burnus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gustav.r.jansen at gmail dot com @ 2021-02-09 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99043
           Summary: Inconsistent behavior when calling rank(ptr) for
                    assumed-rank null pointer
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gustav.r.jansen at gmail dot com
  Target Milestone: ---

Created attachment 50156
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50156&action=edit
Source code that reproduces the described behaviour

Calling rank(ptr) on an assumed-rank null pointer dummy argument returns -1
when the procedure is called with an assumed-rank argument, while it returns
the correct rank when the procedure is called with a non-assumed-rank argument.
The attached file contains a small reproducer to illustrate the behavior.

Here is the output when executed: 
 Lvl1: Expected rank 3, got rank:            3
 Lvl2: Expected rank 3, got rank:           -1

Here is the output of the compiler:
/home/software/gcc/10.2.0/bin/gfortran -v -save-temps -Wall -Wextra
-fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations
-fsanitize=undefined -o assumed_rank.x main.f90
Driving: /home/software/gcc/10.2.0/bin/gfortran -v -save-temps -Wall -Wextra
-fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations
-fsanitize=undefined -o assumed_rank.x main.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=/home/software/gcc/10.2.0/bin/gfortran
COLLECT_LTO_WRAPPER=/home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-10.2.0/configure --prefix=/home/software/gcc/10.2.0
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-fno-aggressive-loop-optimizations' '-fsanitize=undefined' '-o'
'assumed_rank.x' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/f951 main.f90
-quiet -dumpbase main.f90 -mtune=generic -march=x86-64 -auxbase main -Wall
-Wextra -version -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -fsanitize=undefined
-fintrinsic-modules-path
/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/finclude -o main.s
GNU Fortran (GCC) version 10.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 10.2.0, GMP version 6.1.0, MPFR version
3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 10.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 10.2.0, GMP version 6.1.0, MPFR version
3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-fno-aggressive-loop-optimizations' '-fsanitize=undefined' '-o'
'assumed_rank.x' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 as -v --64 -o main.o main.s
GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.30
Reading specs from /home/software/gcc/10.2.0/lib64/../lib64/libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-fno-aggressive-loop-optimizations' '-fsanitize=undefined' '-o'
'assumed_rank.x' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
COMPILER_PATH=/home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/:/home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/:/home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/:/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/home/software/gcc/10.2.0/lib64/../lib64/:/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/:/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/home/software/gcc/10.2.0/lib64/:/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-fno-aggressive-loop-optimizations' '-fsanitize=undefined' '-o'
'assumed_rank.x' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/collect2
-plugin
/home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/liblto_plugin.so
-plugin-opt=/home/software/gcc/10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
-plugin-opt=-fresolution=main.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath
-plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc
--eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o
assumed_rank.x /usr/lib/x86_64-linux-gnu/crt1.o
/usr/lib/x86_64-linux-gnu/crti.o
/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/crtbegin.o
-L/home/software/gcc/10.2.0/lib64/../lib64
-L/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0
-L/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib64
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/home/software/gcc/10.2.0/lib64
-L/home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../.. main.o
-lgfortran -lm -lubsan -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s
-lgcc /home/software/gcc/10.2.0/lib/gcc/x86_64-pc-linux-gnu/10.2.0/crtend.o
/usr/lib/x86_64-linux-gnu/crtn.o
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-aliasing'
'-fwrapv' '-fno-aggressive-loop-optimizations' '-fsanitize=undefined' '-o'
'assumed_rank.x' '-shared-libgcc' '-mtune=generic' '-march=x86-64'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/99043] Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer
  2021-02-09 19:04 [Bug fortran/99043] New: Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer gustav.r.jansen at gmail dot com
@ 2021-02-10 10:30 ` burnus at gcc dot gnu.org
  2021-02-12  8:17 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-02-10 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-02-10
                 CC|                            |burnus at gcc dot gnu.org
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Confirmed, gfortran (-fdump-tree-original) adds an additional 'a->' assignment:

void rank_of_pointer_level1 (struct array15_real(kind=4) & a)
{
...
  if ((real(kind=4)[0:] *) ((struct array15_real(kind=4) *) a)->data == 0B)
    {
      ((struct array15_real(kind=4) *) a)->dtype
         = {.elem_len=4, .rank=-1, .type=3};
    }
  rank_of_pointer_level2 ((struct array15_real(kind=4) *) a);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/99043] Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer
  2021-02-09 19:04 [Bug fortran/99043] New: Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer gustav.r.jansen at gmail dot com
  2021-02-10 10:30 ` [Bug fortran/99043] " burnus at gcc dot gnu.org
@ 2021-02-12  8:17 ` burnus at gcc dot gnu.org
  2021-02-12 13:44 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-02-12  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-February/565195.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/99043] Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer
  2021-02-09 19:04 [Bug fortran/99043] New: Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer gustav.r.jansen at gmail dot com
  2021-02-10 10:30 ` [Bug fortran/99043] " burnus at gcc dot gnu.org
  2021-02-12  8:17 ` burnus at gcc dot gnu.org
@ 2021-02-12 13:44 ` cvs-commit at gcc dot gnu.org
  2021-02-12 15:59 ` cvs-commit at gcc dot gnu.org
  2021-02-12 16:03 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-12 13:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:f699e0b16578cdc1be8b90691ef8b0964af32d2f

commit r11-7209-gf699e0b16578cdc1be8b90691ef8b0964af32d2f
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Fri Feb 12 14:43:41 2021 +0100

    Fortran: Fix rank of assumed-rank array [PR99043]

    gcc/fortran/ChangeLog:

            PR fortran/99043
            * trans-expr.c (gfc_conv_procedure_call): Don't reset
            rank of assumed-rank array.

    gcc/testsuite/ChangeLog:

            PR fortran/99043
            * gfortran.dg/assumed_rank_20.f90: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/99043] Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer
  2021-02-09 19:04 [Bug fortran/99043] New: Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer gustav.r.jansen at gmail dot com
                   ` (2 preceding siblings ...)
  2021-02-12 13:44 ` cvs-commit at gcc dot gnu.org
@ 2021-02-12 15:59 ` cvs-commit at gcc dot gnu.org
  2021-02-12 16:03 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-12 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Tobias Burnus
<burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:f248468b309eba0608608c4d8bd75fd0f4580416

commit r10-9364-gf248468b309eba0608608c4d8bd75fd0f4580416
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Fri Feb 12 14:43:41 2021 +0100

    Fortran: Fix rank of assumed-rank array [PR99043]

    gcc/fortran/ChangeLog:

            PR fortran/99043
            * trans-expr.c (gfc_conv_procedure_call): Don't reset
            rank of assumed-rank array.

    gcc/testsuite/ChangeLog:

            PR fortran/99043
            * gfortran.dg/assumed_rank_20.f90: New test.

    (cherry picked from commit f699e0b16578cdc1be8b90691ef8b0964af32d2f)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/99043] Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer
  2021-02-09 19:04 [Bug fortran/99043] New: Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer gustav.r.jansen at gmail dot com
                   ` (3 preceding siblings ...)
  2021-02-12 15:59 ` cvs-commit at gcc dot gnu.org
@ 2021-02-12 16:03 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-02-12 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED
- on mainline (GCC 11; currently in Stage 4, to be released roughly end of
April, judging by previous releases).
- on the GCC 10 branch
[and, for completeness, on the OG10 alias 'devel/omp/gcc-10' ("OG10") branch
as https://gcc.gnu.org/g:e3020c62ff30567d0eb59c832a040148068b0c79 ]

Thanks for the report!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-12 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 19:04 [Bug fortran/99043] New: Inconsistent behavior when calling rank(ptr) for assumed-rank null pointer gustav.r.jansen at gmail dot com
2021-02-10 10:30 ` [Bug fortran/99043] " burnus at gcc dot gnu.org
2021-02-12  8:17 ` burnus at gcc dot gnu.org
2021-02-12 13:44 ` cvs-commit at gcc dot gnu.org
2021-02-12 15:59 ` cvs-commit at gcc dot gnu.org
2021-02-12 16:03 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).