public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66545] New: ICE on using undefined parameter/variable values
@ 2015-06-15 17:19 gerhard.steinmetz.fortran@t-online.de
  2015-06-15 17:20 ` [Bug fortran/66545] " gerhard.steinmetz.fortran@t-online.de
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-06-15 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66545
           Summary: ICE on using undefined parameter/variable values
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gerhard.steinmetz.fortran@t-online.de
  Target Milestone: ---

This code uses parameter/variable values before they are defined/initialized.

$ cat z1_complex.f90
   program p
      complex, parameter :: c1 = (c1)
      complex, parameter :: c2 = c2
      complex :: c3 = (c3)
      complex :: c4 = c4
      complex :: c5
      complex :: c6
      c5 = (c5)
      c6 = c6
   end


For example, compiling with :

$ gfortran -g -O0 -Wall -fcheck=all -fno-frontend-optimize \
                  -Wuninitialized -fsanitize=undefined \
                  -c z1_complex.f90


yields (with gfortran 5.1.1 on SUSE Linux 13.2, 64 bit) :
f951: internal compiler error: Segmentation fault


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
@ 2015-06-15 17:20 ` gerhard.steinmetz.fortran@t-online.de
  2015-06-15 19:03 ` gerhard.steinmetz.fortran@t-online.de
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-06-15 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
Trivially, the following cases behave similar :


$ cat z1_real.f90
program p
   real, parameter :: c1 = (c1)
   real, parameter :: c2 = c2
   real :: c3 = (c3)
   real :: c4 = c4
   real :: c5
   real :: c6
   c5 = (c5)
   c6 = c6
end


$ cat z1_integer.f90
program p
   integer, parameter :: c1 = (c1)
   integer, parameter :: c2 = c2
   integer :: c3 = (c3)
   integer :: c4 = c4
   integer :: c5
   integer :: c6
   c5 = (c5)
   c6 = c6
end


$ cat z1_logical.f90
program p
   logical, parameter :: c1 = (c1)
   logical, parameter :: c2 = c2
   logical :: c3 = (c3)
   logical :: c4 = c4
   logical :: c5
   logical :: c6
   c5 = (c5)
   c6 = c6
end


$ cat z1_character.f90
program p
   character, parameter :: c1 = (c1)
   character, parameter :: c2 = c2
   character :: c3 = (c3)
   character :: c4 = c4
   character :: c5
   character :: c6
   c5 = (c5)
   c6 = c6
end


$ cat z1_type.f90
program p
   type t; end type
   type(t), parameter :: c1 = (c1)
   type(t), parameter :: c2 = c2
   type(t) :: c3 = (c3)
   type(t) :: c4 = c4
   type(t) :: c5
   type(t) :: c6
   c5 = (c5)
   c6 = c6
end


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
  2015-06-15 17:20 ` [Bug fortran/66545] " gerhard.steinmetz.fortran@t-online.de
@ 2015-06-15 19:03 ` gerhard.steinmetz.fortran@t-online.de
  2015-06-15 20:12 ` tkoenig at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-06-15 19:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
FYI, it's astonishing, but this code compiles without an ICE
and prints some reasonable error messages :


$ cat z2_type.f90
program p
   type t
      integer :: n
   end type
   type(t), parameter :: c1 = (t(c1%n))
   type(t), parameter :: c2 = t(c2%n)
   type(t) :: c3 = (t(c3%n))
   type(t) :: c4 = t(c4%n)
   type(t) :: c5
   type(t) :: c6
   c5 = (t(c5%n))
   c6 = t(c6%n)
end


$ gfortran -c z2_type.f90
z2_type.f90:5:33:

    type(t), parameter :: c1 = (t(c1%n))
                                 1
Error: PARAMETER ‘c1’ is used at (1) before its definition is complete
z2_type.f90:6:32:

    type(t), parameter :: c2 = t(c2%n)
                                1
Error: PARAMETER ‘c2’ is used at (1) before its definition is complete
z2_type.f90:7:22:

    type(t) :: c3 = (t(c3%n))
                      1
Error: Parameter ‘c3’ at (1) has not been declared or is a variable, which does
not reduce to a constant expression
z2_type.f90:8:21:

    type(t) :: c4 = t(c4%n)
                     1
Error: Parameter ‘c4’ at (1) has not been declared or is a variable, which does
not reduce to a constant Expression

#
# c5, c6 differs
#
>From gcc-bugs-return-489032-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jun 15 19:27:56 2015
Return-Path: <gcc-bugs-return-489032-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 130671 invoked by alias); 15 Jun 2015 19:27:55 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 130629 invoked by uid 48); 15 Jun 2015 19:27:51 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/51048] Class template inheritance doesn't work well with function-local types
Date: Mon, 15 Jun 2015 19:27:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.7.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution assigned_to target_milestone
Message-ID: <bug-51048-4-4RGhJd90WS@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-51048-4@http.gcc.gnu.org/bugzilla/>
References: <bug-51048-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-06/txt/msg01364.txt.bz2
Content-length: 575

https://gcc.gnu.org/bugzilla/show_bug.cgi?idQ048

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
           Assignee|paolo.carlini at oracle dot com    |unassigned at gcc dot gnu.org
   Target Milestone|---                         |6.0

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed.


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
  2015-06-15 17:20 ` [Bug fortran/66545] " gerhard.steinmetz.fortran@t-online.de
  2015-06-15 19:03 ` gerhard.steinmetz.fortran@t-online.de
@ 2015-06-15 20:12 ` tkoenig at gcc dot gnu.org
  2015-06-15 20:28 ` kargl at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-06-15 20:12 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-06-15
                 CC|                            |tkoenig at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |tkoenig at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
This fixes the complex part, the others need their own parts.

Index: primary.c
===================================================================
--- primary.c   (Revision 224450)
+++ primary.c   (Arbeitskopie)
@@ -1254,6 +1254,13 @@ match_sym_complex_part (gfc_expr **result)
       return MATCH_ERROR;
     }

+  if (sym->value == NULL)
+    {
+      gfc_error ("PARAMETER %qs is used at %C before its definition "
+                "is complete", sym->name);
+      return MATCH_ERROR;
+    }
+
   if (!gfc_numeric_ts (&sym->value->ts))
     {
       gfc_error ("Numeric PARAMETER required in complex constant at %C");


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
                   ` (2 preceding siblings ...)
  2015-06-15 20:12 ` tkoenig at gcc dot gnu.org
@ 2015-06-15 20:28 ` kargl at gcc dot gnu.org
  2015-06-15 21:19 ` tkoenig at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-06-15 20:28 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to Thomas Koenig from comment #3)
> This fixes the complex part, the others need their own parts.
> 
> Index: primary.c
> ===================================================================
> --- primary.c   (Revision 224450)
> +++ primary.c   (Arbeitskopie)
> @@ -1254,6 +1254,13 @@ match_sym_complex_part (gfc_expr **result)
>        return MATCH_ERROR;
>      }
>  
> +  if (sym->value == NULL)
> +    {
> +      gfc_error ("PARAMETER %qs is used at %C before its definition "
> +                "is complete", sym->name);
> +      return MATCH_ERROR;
> +    }
> +
>    if (!gfc_numeric_ts (&sym->value->ts))
>      {
>        gfc_error ("Numeric PARAMETER required in complex constant at %C");

I have 

  if (!sym->value)
    goto error;

which leads to the same error.


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
                   ` (3 preceding siblings ...)
  2015-06-15 20:28 ` kargl at gcc dot gnu.org
@ 2015-06-15 21:19 ` tkoenig at gcc dot gnu.org
  2015-06-15 21:35 ` sgk at troutmask dot apl.washington.edu
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-06-15 21:19 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|tkoenig at gcc dot gnu.org         |unassigned at gcc dot gnu.org

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---

> I have 
> 
>   if (!sym->value)
>     goto error;
> 
> which leads to the same error.

I think your approach is better.

Your bug :-)


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
                   ` (4 preceding siblings ...)
  2015-06-15 21:19 ` tkoenig at gcc dot gnu.org
@ 2015-06-15 21:35 ` sgk at troutmask dot apl.washington.edu
  2015-06-16 19:59 ` tkoenig at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-06-15 21:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Jun 15, 2015 at 09:19:45PM +0000, tkoenig at gcc dot gnu.org wrote:
> 
> > I have 
> > 
> >   if (!sym->value)
> >     goto error;
> > 
> > which leads to the same error.
> 
> I think your approach is better.
> 
> Your bug :-)
> 

This passes regression testing.  So, do I have
your approval (with an appropriate testcase of
course)?


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
                   ` (5 preceding siblings ...)
  2015-06-15 21:35 ` sgk at troutmask dot apl.washington.edu
@ 2015-06-16 19:59 ` tkoenig at gcc dot gnu.org
  2015-07-02 17:02 ` kargl at gcc dot gnu.org
  2015-07-16 19:04 ` kargl at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-06-16 19:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #6)
> On Mon, Jun 15, 2015 at 09:19:45PM +0000, tkoenig at gcc dot gnu.org wrote:
> > 
> > > I have 
> > > 
> > >   if (!sym->value)
> > >     goto error;
> > > 
> > > which leads to the same error.
> > 
> > I think your approach is better.
> > 
> > Your bug :-)
> > 
> 
> This passes regression testing.  So, do I have
> your approval (with an appropriate testcase of
> course)?

Pre-approved for a test case which contains all of Gerhard's test
cases.


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
                   ` (6 preceding siblings ...)
  2015-06-16 19:59 ` tkoenig at gcc dot gnu.org
@ 2015-07-02 17:02 ` kargl at gcc dot gnu.org
  2015-07-16 19:04 ` kargl at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-02 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jul  2 17:02:10 2015
New Revision: 225348

URL: https://gcc.gnu.org/viewcvs?rev=225348&root=gcc&view=rev
Log:
2015-07-02  Steven G. Kargl   <kargl@gcc.gnu.org>

        PR fortran/66545
        * primary.c (match_sym_complex_part): Do not dereference NULL pointer.

2015-07-02  Steven G. Kargl   <kargl@gcc.gnu.org>

        PR fortran/66545
        * gfortran.dg/pr66545_1.f90: New test.
        * gfortran.dg/pr66545_2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr66545_1.f90
    trunk/gcc/testsuite/gfortran.dg/pr66545_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/primary.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/66545] ICE on using undefined parameter/variable values
  2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
                   ` (7 preceding siblings ...)
  2015-07-02 17:02 ` kargl at gcc dot gnu.org
@ 2015-07-16 19:04 ` kargl at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-16 19:04 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.3

--- Comment #10 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch.  Thanks for the bug report.


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

end of thread, other threads:[~2015-07-16 19:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 17:19 [Bug fortran/66545] New: ICE on using undefined parameter/variable values gerhard.steinmetz.fortran@t-online.de
2015-06-15 17:20 ` [Bug fortran/66545] " gerhard.steinmetz.fortran@t-online.de
2015-06-15 19:03 ` gerhard.steinmetz.fortran@t-online.de
2015-06-15 20:12 ` tkoenig at gcc dot gnu.org
2015-06-15 20:28 ` kargl at gcc dot gnu.org
2015-06-15 21:19 ` tkoenig at gcc dot gnu.org
2015-06-15 21:35 ` sgk at troutmask dot apl.washington.edu
2015-06-16 19:59 ` tkoenig at gcc dot gnu.org
2015-07-02 17:02 ` kargl at gcc dot gnu.org
2015-07-16 19:04 ` kargl 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).