public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
@ 2020-06-23 9:54 burnus at gcc dot gnu.org
2020-06-23 16:44 ` [Bug fortran/95837] " dominiq at lps dot ens.fr
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-06-23 9:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
Bug ID: 95837
Summary: derived-type components of character kind=4 – wrong
code with component access (kind=4 ignored)
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
Compare:
---------------
type t
character(len=:, kind=4), pointer :: str2
end type t
type(t) :: var
character(len=:, kind=4), pointer :: str
str(1:1) = 4_"a"
str(1:2) = 4_"bc"
var%str2(1:1) = 4_"d"
var%str2(1:2) = 4_"ef"
end
---------------
The dump shows that 'str' is properly handled:
(*str)[1]{lb: 1 sz: 4} = "a\x00\x00"[1]{lb: 1 sz: 4};
__builtin_memmove ((void *) str,
(void *) &"b\x00\x00\x00c\x00\x00"[1]{lb: 1 sz: 4}, 8);
But the component reference ignores the kind=4:
*(character(kind=1) *) var.str2 = 100;
__builtin_memmove ((void *) var.str2,
(void *) &"ef"[1]{lb: 1 sz: 1}, 2);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
@ 2020-06-23 16:44 ` dominiq at lps dot ens.fr
2020-06-23 17:27 ` kargl at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-06-23 16:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2020-06-23
Status|UNCONFIRMED |WAITING
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The problem seems more serious.
type t
character(len=:, kind=4), pointer :: str2
end type t
type(t) :: var
character(len=:, kind=4), pointer :: str
print *, kind(str), kind(var%str2)
str(1:1) = 4_"a"
end
result
% ./a.out
4 4
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
2020-06-23 16:44 ` [Bug fortran/95837] " dominiq at lps dot ens.fr
@ 2020-06-23 17:27 ` kargl at gcc dot gnu.org
2020-06-23 18:29 ` kargl at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-06-23 17:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #1)
> The problem seems more serious.
>
> type t
> character(len=:, kind=4), pointer :: str2
> end type t
> type(t) :: var
> character(len=:, kind=4), pointer :: str
>
> print *, kind(str), kind(var%str2)
> str(1:1) = 4_"a"
> end
>
> result
>
> % ./a.out
> 4 4
Yes, there is a serious problem with the Fortran code!
str is an undefined pointer. The line 'str(1:1) = 4_"a"'
is invalid.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
2020-06-23 16:44 ` [Bug fortran/95837] " dominiq at lps dot ens.fr
2020-06-23 17:27 ` kargl at gcc dot gnu.org
@ 2020-06-23 18:29 ` kargl at gcc dot gnu.org
2020-06-23 21:11 ` kargl at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-06-23 18:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
--- Comment #3 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> (In reply to Dominique d'Humieres from comment #1)
> > The problem seems more serious.
> >
> > type t
> > character(len=:, kind=4), pointer :: str2
> > end type t
> > type(t) :: var
> > character(len=:, kind=4), pointer :: str
> >
> > print *, kind(str), kind(var%str2)
> > str(1:1) = 4_"a"
> > end
> >
> > result
> >
> > % ./a.out
> > 4 4
>
> Yes, there is a serious problem with the Fortran code!
>
> str is an undefined pointer. The line 'str(1:1) = 4_"a"'
> is invalid.
In fact, after a quick scan of the Fortran 2018 standard.
The PR is likely invalid. Allocation on assignment applies
to ALLOCATABLE variables not undefined or disassociated
pointers.
Yep. Definitely invalid.
Fortran 2018,
10.2.1.2 Intrinsic assignment statement
p. 160
If the variable is a pointer, it shall be associated with a definable
target such that the type, type parameters, and shape of the target and
expr conform.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2020-06-23 18:29 ` kargl at gcc dot gnu.org
@ 2020-06-23 21:11 ` kargl at gcc dot gnu.org
2020-06-24 7:16 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-06-23 21:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
Keywords|wrong-code |
--- Comment #4 from kargl at gcc dot gnu.org ---
Remove "wrong-code" keyword.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2020-06-23 21:11 ` kargl at gcc dot gnu.org
@ 2020-06-24 7:16 ` burnus at gcc dot gnu.org
2020-06-25 14:59 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-06-24 7:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Keywords| |rejects-valid, wrong-code
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2020-June/548779.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2020-06-24 7:16 ` burnus at gcc dot gnu.org
@ 2020-06-25 14:59 ` cvs-commit at gcc dot gnu.org
2020-06-25 15:00 ` burnus at gcc dot gnu.org
2020-07-15 10:34 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-25 14:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:
https://gcc.gnu.org/g:f48bffe70cba310461ec19ffcd07c573a6b86575
commit r11-1654-gf48bffe70cba310461ec19ffcd07c573a6b86575
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Thu Jun 25 16:57:08 2020 +0200
Fortran: Fix character-kind=4 substring resolution (PR95837)
Testing showed that it is always set and its value matches
always ts->kind (if available) or otherwise, if it is a variable,
the sym->ts.kind.
gcc/fortran/ChangeLog:
PR fortran/95837
* resolve.c (gfc_resolve_substring_charlen): Remove
bogus ts.kind setting for the expression.
gcc/testsuite/ChangeLog:
PR fortran/95837
* gfortran.dg/char4-subscript.f90: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2020-06-25 14:59 ` cvs-commit at gcc dot gnu.org
@ 2020-06-25 15:00 ` burnus at gcc dot gnu.org
2020-07-15 10:34 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-06-25 15:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on mainline = GCC 11.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/95837] derived-type components of character kind=4 – wrong code with component access (kind=4 ignored)
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
` (6 preceding siblings ...)
2020-06-25 15:00 ` burnus at gcc dot gnu.org
@ 2020-07-15 10:34 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-15 10:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95837
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:
https://gcc.gnu.org/g:e0685fadb6aa7c9cc895bc14cbbe2b9026fa3a94
commit r11-2105-ge0685fadb6aa7c9cc895bc14cbbe2b9026fa3a94
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Wed Jul 15 12:29:44 2020 +0200
libgomp.fortran/struct-elem-map-1.f90: Add char kind=4 tests
As the Fortran PR 95837 has been fixed, the test could be be added.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/struct-elem-map-1.f90: Remove unused
variables; add character(kind=4) tests; update TODO comment.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-07-15 10:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 9:54 [Bug fortran/95837] New: derived-type components of character kind=4 – wrong code with component access (kind=4 ignored) burnus at gcc dot gnu.org
2020-06-23 16:44 ` [Bug fortran/95837] " dominiq at lps dot ens.fr
2020-06-23 17:27 ` kargl at gcc dot gnu.org
2020-06-23 18:29 ` kargl at gcc dot gnu.org
2020-06-23 21:11 ` kargl at gcc dot gnu.org
2020-06-24 7:16 ` burnus at gcc dot gnu.org
2020-06-25 14:59 ` cvs-commit at gcc dot gnu.org
2020-06-25 15:00 ` burnus at gcc dot gnu.org
2020-07-15 10:34 ` 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).