public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49278] ICE (segfault) when combining DATA with default initialization Date: Tue, 22 Dec 2020 20:36:19 +0000 [thread overview] Message-ID: <bug-49278-4-F5IMfbmy5J@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-49278-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49278 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org Keywords| |ice-on-valid-code, | |wrong-code --- Comment #21 from anlauf at gcc dot gnu.org --- There's also valid code that ICEs, and invalid code that is silently accepted. Invalid code: program p implicit none integer, parameter :: b = 1 data b / 2 / print *, b end Instead of being rejected, this prints: 1 One could catch this one in gfc_assign_data_value, but I haven't found out yet how to get this right with derived type components, so there's possibly a better place. And after fixing an obvious NULL pointer dereference, diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 37a0c85fa30..783a0bbddcc 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -5520,7 +5520,7 @@ check_constant_initializer (gfc_expr *expr, gfc_typespec *ts, bool array, return false; cm = expr->ts.u.derived->components; for (c = gfc_constructor_first (expr->value.constructor); - c; c = gfc_constructor_next (c), cm = cm->next) + c && cm; c = gfc_constructor_next (c), cm = cm->next) { if (!c->expr || cm->attr.allocatable) continue; we arrive at wrong code on valid input: program p implicit none type t real :: a end type t type(t) :: z = t(4.0) data z%a /3.0/ print *, z%a end This now prints 4.00000000
next prev parent reply other threads:[~2020-12-22 20:36 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-06-03 15:19 [Bug fortran/49278] New: internal compiler error: Segmentation fault petrielmjr at ornl dot gov 2011-06-03 16:08 ` [Bug fortran/49278] " kargl at gcc dot gnu.org 2011-06-03 18:11 ` sgk at troutmask dot apl.washington.edu 2011-06-06 8:23 ` burnus at gcc dot gnu.org 2011-06-07 9:17 ` [Bug fortran/49278] ICE (segfault) when combining DATA with default initialization burnus at gcc dot gnu.org 2011-06-08 5:55 ` burnus at gcc dot gnu.org 2011-06-14 12:32 ` burnus at gcc dot gnu.org 2011-06-30 12:26 ` thenlich at users dot sourceforge.net 2011-06-30 12:34 ` burnus at gcc dot gnu.org 2020-12-22 20:36 ` anlauf at gcc dot gnu.org [this message] 2020-12-22 20:43 ` anlauf at gcc dot gnu.org 2020-12-22 21:24 ` kargl at gcc dot gnu.org 2020-12-22 21:31 ` kargl at gcc dot gnu.org 2020-12-22 21:34 ` anlauf at gcc dot gnu.org 2020-12-22 21:36 ` anlauf at gcc dot gnu.org 2020-12-22 21:49 ` kargl at gcc dot gnu.org 2021-03-01 22:17 ` anlauf at gcc dot gnu.org 2021-03-08 21:00 ` cvs-commit at gcc dot gnu.org 2021-03-09 8:34 ` zeccav at gmail dot com 2024-04-04 19:54 ` anlauf at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-49278-4-F5IMfbmy5J@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).