public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/103475] New: ICE in gfc_expr_attr, at fortran/primary.c:2782
@ 2021-11-29 18:52 gscfq@t-online.de
  2021-11-29 19:44 ` [Bug fortran/103475] " kargl at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2021-11-29 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103475
           Summary: ICE in gfc_expr_attr, at fortran/primary.c:2782
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

With option -Wall and a missing attribute allocatable or pointer :
(affects version down to at least r5)
(gcc configured with --enable-checking=yes)


$ cat z1.f90
program p
   type t
   end type
   class(t) :: x
   y = x()
end


$ gfortran-12-20211128 -c z1.f90 -Wall
z1.f90:4:16:

    4 |    class(t) :: x
      |                1
Error: CLASS variable 'x' at (1) must be dummy, allocatable or pointer
f951: internal compiler error: Segmentation fault
0xf0942f crash_signal
        ../../gcc/toplev.c:322
0x842464 gfc_expr_attr(gfc_expr*)
        ../../gcc/fortran/primary.c:2782
0x7e02eb gfc_check_assign(gfc_expr*, gfc_expr*, int, bool)
        ../../gcc/fortran/expr.c:3734
0x84a6d5 resolve_ordinary_assign
        ../../gcc/fortran/resolve.c:11188
0x852a3c gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.c:12047
0x854f97 resolve_codes
        ../../gcc/fortran/resolve.c:17536
0x85505e gfc_resolve(gfc_namespace*)
        ../../gcc/fortran/resolve.c:17571
0x83d314 resolve_all_program_units
        ../../gcc/fortran/parse.c:6573
0x83d314 gfc_parse_file()
        ../../gcc/fortran/parse.c:6829
0x88b37f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:216

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

* [Bug fortran/103475] ICE in gfc_expr_attr, at fortran/primary.c:2782
  2021-11-29 18:52 [Bug fortran/103475] New: ICE in gfc_expr_attr, at fortran/primary.c:2782 gscfq@t-online.de
@ 2021-11-29 19:44 ` kargl at gcc dot gnu.org
  2022-01-18 20:53 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2021-11-29 19:44 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-29
     Ever confirmed|0                           |1
           Priority|P3                          |P4

--- Comment #1 from kargl at gcc dot gnu.org ---
Classic NULL pointer dereference.

diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index d873264a08e..0cb783dfc66 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -2777,7 +2777,7 @@ gfc_expr_attr (gfc_expr *e)
        {
          gfc_symbol *sym = e->value.function.esym->result;
          attr = sym->attr;
-         if (sym->ts.type == BT_CLASS)
+         if (sym->ts.type == BT_CLASS && CLASS_DATA (sym))
            {
              attr.dimension = CLASS_DATA (sym)->attr.dimension;
              attr.pointer = CLASS_DATA (sym)->attr.class_pointer;

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

* [Bug fortran/103475] ICE in gfc_expr_attr, at fortran/primary.c:2782
  2021-11-29 18:52 [Bug fortran/103475] New: ICE in gfc_expr_attr, at fortran/primary.c:2782 gscfq@t-online.de
  2021-11-29 19:44 ` [Bug fortran/103475] " kargl at gcc dot gnu.org
@ 2022-01-18 20:53 ` anlauf at gcc dot gnu.org
  2023-02-13 20:05 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-18 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #2 from anlauf at gcc dot gnu.org ---
While the patch in comment#1 looks correct, I don't see the ICE for r12-6697.
Running under gdb shows why: we seem to no longer get here.

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

* [Bug fortran/103475] ICE in gfc_expr_attr, at fortran/primary.c:2782
  2021-11-29 18:52 [Bug fortran/103475] New: ICE in gfc_expr_attr, at fortran/primary.c:2782 gscfq@t-online.de
  2021-11-29 19:44 ` [Bug fortran/103475] " kargl at gcc dot gnu.org
  2022-01-18 20:53 ` anlauf at gcc dot gnu.org
@ 2023-02-13 20:05 ` anlauf at gcc dot gnu.org
  2023-02-13 21:06 ` cvs-commit at gcc dot gnu.org
  2023-02-13 21:14 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-02-13 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org
             Status|WAITING                     |ASSIGNED

--- Comment #3 from anlauf at gcc dot gnu.org ---
Can reproduce now.  Taking.

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

* [Bug fortran/103475] ICE in gfc_expr_attr, at fortran/primary.c:2782
  2021-11-29 18:52 [Bug fortran/103475] New: ICE in gfc_expr_attr, at fortran/primary.c:2782 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2023-02-13 20:05 ` anlauf at gcc dot gnu.org
@ 2023-02-13 21:06 ` cvs-commit at gcc dot gnu.org
  2023-02-13 21:14 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-13 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:2ce7e2a83e18a27fe9c659f8667fc24f0df4ea9a

commit r13-5970-g2ce7e2a83e18a27fe9c659f8667fc24f0df4ea9a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Feb 13 22:02:44 2023 +0100

    Fortran: error recovery after invalid use of CLASS variable [PR103475]

    gcc/fortran/ChangeLog:

            PR fortran/103475
            * primary.cc (gfc_expr_attr): Avoid NULL pointer dereference for
            invalid use of CLASS variable.

    gcc/testsuite/ChangeLog:

            PR fortran/103475
            * gfortran.dg/pr103475.f90: New test.

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

* [Bug fortran/103475] ICE in gfc_expr_attr, at fortran/primary.c:2782
  2021-11-29 18:52 [Bug fortran/103475] New: ICE in gfc_expr_attr, at fortran/primary.c:2782 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2023-02-13 21:06 ` cvs-commit at gcc dot gnu.org
@ 2023-02-13 21:14 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-02-13 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from anlauf at gcc dot gnu.org ---
Fixed on mainline.

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

end of thread, other threads:[~2023-02-13 21:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 18:52 [Bug fortran/103475] New: ICE in gfc_expr_attr, at fortran/primary.c:2782 gscfq@t-online.de
2021-11-29 19:44 ` [Bug fortran/103475] " kargl at gcc dot gnu.org
2022-01-18 20:53 ` anlauf at gcc dot gnu.org
2023-02-13 20:05 ` anlauf at gcc dot gnu.org
2023-02-13 21:06 ` cvs-commit at gcc dot gnu.org
2023-02-13 21:14 ` anlauf 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).