public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100551] New: [11/12 Regression] Passing return value of intrinsic to class(*) dummy argument can cause segfaults
@ 2021-05-11 21:32 bugs at colin dot moe
  2021-05-12  7:12 ` [Bug fortran/100551] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bugs at colin dot moe @ 2021-05-11 21:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100551
           Summary: [11/12 Regression] Passing return value of intrinsic
                    to class(*) dummy argument can cause segfaults
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugs at colin dot moe
  Target Milestone: ---

Created attachment 50794
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50794&action=edit
Minimum working example that induces the error.

When passing the return value of an intrinsic function (and possibly other
temporaries) into a function with a class(*) dummy argument, the resulting code
will generate a segfault in GCC 11.1 and newer.  10.2 and earlier (as early as
4.8.5 tested) worked correctly.

Minimum working example attached.

GCC Version (latest tested):

Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib
--enable-languages=c,c++,fortran --with-system-zlib --prefix=[]/gcc-12.0
gcc version 12.0.0 20210511 (experimental) (GCC) 

Command line:
gfortran -Wall -Wextra mwe.f90
./a.out

Output:
Compiler builds with no issues.  In GCC 4.8.5, 9.3.0, 10.2.0, the program
output is:
15

In 11.1.0 and 12.0 (tested against master branch for 12.0):
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7f6e7a218f7f in ???
#1  0x401323 in __testmod_MOD_test
        at []/mwe.f90:15
#2  0x4015b2 in testprogram
        at []/mwe.f90:26
#3  0x40165b in main
        at []/mwe.f90:18
[1]    626265 segmentation fault (core dumped)  ./a.out

Output with -fsanitize=undefined:
mwe.f90:15:10: runtime error: member access within misaligned address
0x7ffc6198b024 for type 'struct __class__STAR_t', which requires 8 byte
alignment
0x7ffc6198b024: note: pointer points here
  60 49 30 ef 0f 00 00 00  00 00 00 00 00 00 00 00  01 00 00 00 02 00 00 00  03
00 00 00 04 00 00 00
              ^

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

end of thread, other threads:[~2022-01-07 17:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 21:32 [Bug fortran/100551] New: [11/12 Regression] Passing return value of intrinsic to class(*) dummy argument can cause segfaults bugs at colin dot moe
2021-05-12  7:12 ` [Bug fortran/100551] " rguenth at gcc dot gnu.org
2021-05-12  9:41 ` marxin at gcc dot gnu.org
2021-05-12 20:22 ` anlauf at gcc dot gnu.org
2021-05-12 21:11 ` anlauf at gcc dot gnu.org
2021-05-13  7:41 ` anlauf at gcc dot gnu.org
2021-05-20 21:30 ` anlauf at gcc dot gnu.org
2021-05-23 18:52 ` cvs-commit at gcc dot gnu.org
2021-05-25 20:13 ` cvs-commit at gcc dot gnu.org
2021-05-25 20:16 ` anlauf at gcc dot gnu.org
2022-01-07 17:47 ` cvs-commit 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).