* [Bug fortran/116530] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
@ 2024-08-29 15:37 ` kargls at comcast dot net
2024-08-29 17:13 ` [Bug fortran/116530] [14/15 Regression] " anlauf at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargls at comcast dot net @ 2024-08-29 15:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
kargls at comcast dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargls at comcast dot net
--- Comment #1 from kargls at comcast dot net ---
(In reply to philippe.wautelet from comment #0)
>
> I'm not sure it is conforming to the Fortran standard but it shouldn't
> trigger an ICE.
>
I agree with you about the ICE should not happen. Staring at F2023,
I find the following constraint.
C8107 (R871) The namelist-group-name shall not be a name accessed by use
association.
If I understand it, your code is nonstandard. But, I don't use namelist, so
will need to read through the Fortran standard a bit more.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
2024-08-29 15:37 ` [Bug fortran/116530] " kargls at comcast dot net
@ 2024-08-29 17:13 ` anlauf at gcc dot gnu.org
2024-08-29 17:23 ` anlauf at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-08-29 17:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
Summary|ICE with member of namelist |[14/15 Regression] ICE with
|renamed by use module |member of namelist renamed
| |by use module
Ever confirmed|0 |1
CC| |anlauf at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Priority|P3 |P4
Known to work| |13.3.0
Target Milestone|--- |14.3
Known to fail| |14.1.0, 14.2.0, 15.0
Last reconfirmed| |2024-08-29
--- Comment #2 from anlauf at gcc dot gnu.org ---
Reduced testcase:
module mod_nml1
logical :: ldiag
namelist /nam_nml1/ldiag
end module mod_nml1
module mod_interm
use mod_nml1
end module mod_interm
program ice_nml
! Interchanging the following two lines fixes the ICE:
use mod_nml1, ldiag_nml1 => ldiag
use mod_interm
integer :: ilu
read(unit=ilu,nml=nam_nml1)
end program ice_nml
Works with Intel, NAG, Nvidia, flang.
As written above, interchanging the use statements fixes the ICE.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
2024-08-29 15:37 ` [Bug fortran/116530] " kargls at comcast dot net
2024-08-29 17:13 ` [Bug fortran/116530] [14/15 Regression] " anlauf at gcc dot gnu.org
@ 2024-08-29 17:23 ` anlauf at gcc dot gnu.org
2024-08-29 17:32 ` anlauf at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-08-29 17:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #3 from anlauf at gcc dot gnu.org ---
Tentative obvious fix for NULL pointer dereference:
diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
index 7ab82fa2f5b..de38f4a808f 100644
--- a/gcc/fortran/trans-io.cc
+++ b/gcc/fortran/trans-io.cc
@@ -1692,7 +1692,8 @@ transfer_namelist_element (stmtblock_t * block, const
char * var_name,
gcc_assert (sym || c);
/* Build the namelist object name. */
- if (sym && !sym->attr.use_only && sym->attr.use_rename)
+ if (sym && !sym->attr.use_only && sym->attr.use_rename
+ && sym->ns->use_stmts->rename)
string = gfc_build_cstring_const (sym->ns->use_stmts->rename->local_name);
else
string = gfc_build_cstring_const (var_name);
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (2 preceding siblings ...)
2024-08-29 17:23 ` anlauf at gcc dot gnu.org
@ 2024-08-29 17:32 ` anlauf at gcc dot gnu.org
2024-08-29 18:47 ` kargls at comcast dot net
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-08-29 17:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to kargls from comment #1)
> (In reply to philippe.wautelet from comment #0)
>
> >
> > I'm not sure it is conforming to the Fortran standard but it shouldn't
> > trigger an ICE.
> >
>
> I agree with you about the ICE should not happen. Staring at F2023,
> I find the following constraint.
>
> C8107 (R871) The namelist-group-name shall not be a name accessed by use
> association.
>
> If I understand it, your code is nonstandard. But, I don't use namelist, so
> will need to read through the Fortran standard a bit more.
This constraint applies to the namelist statement and does not apply to the
issue here.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (3 preceding siblings ...)
2024-08-29 17:32 ` anlauf at gcc dot gnu.org
@ 2024-08-29 18:47 ` kargls at comcast dot net
2024-08-29 19:02 ` kargls at comcast dot net
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargls at comcast dot net @ 2024-08-29 18:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #5 from kargls at comcast dot net ---
(In reply to anlauf from comment #4)
> (In reply to kargls from comment #1)
> > (In reply to philippe.wautelet from comment #0)
> >
> > >
> > > I'm not sure it is conforming to the Fortran standard but it shouldn't
> > > trigger an ICE.
> > >
> >
> > I agree with you about the ICE should not happen. Staring at F2023,
> > I find the following constraint.
> >
> > C8107 (R871) The namelist-group-name shall not be a name accessed by use
> > association.
> >
> > If I understand it, your code is nonstandard. But, I don't use namelist, so
> > will need to read through the Fortran standard a bit more.
>
> This constraint applies to the namelist statement and does not apply to the
> issue here.
Yeah, I needed to review more the Fortran, and you beat me
to working out a patch. The '(R871)' above restricts the
constraint to namelist statement. However, this did lead to
module mod_nml1
implicit none
logical :: ldiag
namelist /nam_nml1/ldiag
end module mod_nml1
program ice_nml
use mod_nml1
implicit none
integer :: ilu, j
namelist /nam_nml1/j !<-- Does this violates C8107?
ldiag = .false.
j = 42
write(*,nml=nam_nml1)
end program ice_nml
% gfcx -o z a.f90 && ./z
&NAM_NML1
LDIAG=F,
J=42 ,
/
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (4 preceding siblings ...)
2024-08-29 18:47 ` kargls at comcast dot net
@ 2024-08-29 19:02 ` kargls at comcast dot net
2024-08-29 19:03 ` anlauf at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargls at comcast dot net @ 2024-08-29 19:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #6 from kargls at comcast dot net ---
(In reply to anlauf from comment #3)
> Tentative obvious fix for NULL pointer dereference:
>
> diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
> index 7ab82fa2f5b..de38f4a808f 100644
> --- a/gcc/fortran/trans-io.cc
> +++ b/gcc/fortran/trans-io.cc
> @@ -1692,7 +1692,8 @@ transfer_namelist_element (stmtblock_t * block, const
> char * var_name,
> gcc_assert (sym || c);
>
> /* Build the namelist object name. */
> - if (sym && !sym->attr.use_only && sym->attr.use_rename)
> + if (sym && !sym->attr.use_only && sym->attr.use_rename
> + && sym->ns->use_stmts->rename)
> string = gfc_build_cstring_const
> (sym->ns->use_stmts->rename->local_name);
> else
> string = gfc_build_cstring_const (var_name);
Patch looks good. If it passes regression testing, you can commit it you want.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (5 preceding siblings ...)
2024-08-29 19:02 ` kargls at comcast dot net
@ 2024-08-29 19:03 ` anlauf at gcc dot gnu.org
2024-08-29 19:06 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-08-29 19:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #7 from anlauf at gcc dot gnu.org ---
(In reply to kargls from comment #5)
> (In reply to anlauf from comment #4)
> > (In reply to kargls from comment #1)
> > > (In reply to philippe.wautelet from comment #0)
> > >
> > > >
> > > > I'm not sure it is conforming to the Fortran standard but it shouldn't
> > > > trigger an ICE.
> > > >
> > >
> > > I agree with you about the ICE should not happen. Staring at F2023,
> > > I find the following constraint.
> > >
> > > C8107 (R871) The namelist-group-name shall not be a name accessed by use
> > > association.
> > >
> > > If I understand it, your code is nonstandard. But, I don't use namelist, so
> > > will need to read through the Fortran standard a bit more.
> >
> > This constraint applies to the namelist statement and does not apply to the
> > issue here.
>
> Yeah, I needed to review more the Fortran, and you beat me
> to working out a patch. The '(R871)' above restricts the
> constraint to namelist statement. However, this did lead to
>
> module mod_nml1
> implicit none
> logical :: ldiag
> namelist /nam_nml1/ldiag
> end module mod_nml1
>
> program ice_nml
> use mod_nml1
> implicit none
> integer :: ilu, j
> namelist /nam_nml1/j !<-- Does this violates C8107?
Yes, that is illegal and rejected by Intel and NAG, e.g.:
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7200
Error: iii.f90, line 11: Redeclaration of symbol NAM_NML1 from USEd module
MOD_NML1
detected at /@NAM_NML1
Warning: iii.f90, line 15: Unused local variable ILU
[NAG Fortran Compiler pass 1 error termination, 1 error, 1 warning]
I think we should track that constraint violation separately (no regression)
from the present PR (regression).
> ldiag = .false.
> j = 42
> write(*,nml=nam_nml1)
> end program ice_nml
>
> % gfcx -o z a.f90 && ./z
> &NAM_NML1
> LDIAG=F,
> J=42 ,
> /
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (6 preceding siblings ...)
2024-08-29 19:03 ` anlauf at gcc dot gnu.org
@ 2024-08-29 19:06 ` anlauf at gcc dot gnu.org
2024-08-29 19:23 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-08-29 19:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #8 from anlauf at gcc dot gnu.org ---
(In reply to kargls from comment #6)
> (In reply to anlauf from comment #3)
> > Tentative obvious fix for NULL pointer dereference:
> >
> > diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
> > index 7ab82fa2f5b..de38f4a808f 100644
> > --- a/gcc/fortran/trans-io.cc
> > +++ b/gcc/fortran/trans-io.cc
> > @@ -1692,7 +1692,8 @@ transfer_namelist_element (stmtblock_t * block, const
> > char * var_name,
> > gcc_assert (sym || c);
> >
> > /* Build the namelist object name. */
> > - if (sym && !sym->attr.use_only && sym->attr.use_rename)
> > + if (sym && !sym->attr.use_only && sym->attr.use_rename
> > + && sym->ns->use_stmts->rename)
> > string = gfc_build_cstring_const
> > (sym->ns->use_stmts->rename->local_name);
> > else
> > string = gfc_build_cstring_const (var_name);
>
> Patch looks good. If it passes regression testing, you can commit it you
> want.
Yes, it passed. I was just packaging it for submission, but given your OK
I will push to master and inform the list.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (7 preceding siblings ...)
2024-08-29 19:06 ` anlauf at gcc dot gnu.org
@ 2024-08-29 19:23 ` cvs-commit at gcc dot gnu.org
2024-08-29 19:33 ` anlauf at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-29 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #9 from GCC 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:6bfeba12c86b4d0dae27d99b484f64774dd49398
commit r15-3308-g6bfeba12c86b4d0dae27d99b484f64774dd49398
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Aug 29 21:21:39 2024 +0200
Fortran: fix ICE with use with rename of namelist member [PR116530]
gcc/fortran/ChangeLog:
PR fortran/116530
* trans-io.cc (transfer_namelist_element): Prevent NULL pointer
dereference.
gcc/testsuite/ChangeLog:
PR fortran/116530
* gfortran.dg/use_rename_12.f90: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (8 preceding siblings ...)
2024-08-29 19:23 ` cvs-commit at gcc dot gnu.org
@ 2024-08-29 19:33 ` anlauf at gcc dot gnu.org
2024-08-30 16:20 ` cvs-commit at gcc dot gnu.org
2024-08-30 16:32 ` anlauf at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-08-29 19:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
--- Comment #10 from anlauf at gcc dot gnu.org ---
Fixed on mainline so far.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (9 preceding siblings ...)
2024-08-29 19:33 ` anlauf at gcc dot gnu.org
@ 2024-08-30 16:20 ` cvs-commit at gcc dot gnu.org
2024-08-30 16:32 ` anlauf at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-30 16:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:5999dd8a610acbaff9dfb6bdeb67f33380336132
commit r14-10621-g5999dd8a610acbaff9dfb6bdeb67f33380336132
Author: Harald Anlauf <anlauf@gmx.de>
Date: Thu Aug 29 21:21:39 2024 +0200
Fortran: fix ICE with use with rename of namelist member [PR116530]
gcc/fortran/ChangeLog:
PR fortran/116530
* trans-io.cc (transfer_namelist_element): Prevent NULL pointer
dereference.
gcc/testsuite/ChangeLog:
PR fortran/116530
* gfortran.dg/use_rename_12.f90: New test.
(cherry picked from commit 6bfeba12c86b4d0dae27d99b484f64774dd49398)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/116530] [14/15 Regression] ICE with member of namelist renamed by use module
2024-08-29 6:38 [Bug fortran/116530] New: ICE with member of namelist renamed by use module philippe.wautelet at cnrs dot fr
` (10 preceding siblings ...)
2024-08-30 16:20 ` cvs-commit at gcc dot gnu.org
@ 2024-08-30 16:32 ` anlauf at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-08-30 16:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116530
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #12 from anlauf at gcc dot gnu.org ---
Backported to 14-branch. Closing.
Thanks for the report!
^ permalink raw reply [flat|nested] 13+ messages in thread