public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100683] New: Array initialization refuses valid
@ 2021-05-19 15:23 jrfsousa at gcc dot gnu.org
  2021-05-19 17:16 ` [Bug fortran/100683] " jrfsousa at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-05-19 15:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100683
           Summary: Array initialization refuses valid
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jrfsousa at gcc dot gnu.org
  Target Milestone: ---

Created attachment 50846
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50846&action=edit
Fortran code showing problem

Hi All!

Refuses valid array initialization with bogus error.

Seen on:

GNU Fortran (GCC) 9.3.1 20210514
GNU Fortran (GCC) 10.3.1 20210514
GNU Fortran (GCC) 11.1.1 20210514
GNU Fortran (GCC) 12.0.0 20210514 (experimental)

Thank you very much.

Best regards,
José Rui

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
@ 2021-05-19 17:16 ` jrfsousa at gcc dot gnu.org
  2021-05-31 10:51 ` dominiq at lps dot ens.fr
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-05-19 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> ---
Patch posted:

https://gcc.gnu.org/pipermail/fortran/2021-May/056053.html

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
  2021-05-19 17:16 ` [Bug fortran/100683] " jrfsousa at gcc dot gnu.org
@ 2021-05-31 10:51 ` dominiq at lps dot ens.fr
  2021-05-31 15:44 ` dominiq at lps dot ens.fr
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-05-31 10:51 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-05-31
     Ever confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Patch posted:
>
> https://gcc.gnu.org/pipermail/fortran/2021-May/056053.html

The patch fixes this PR, however I see an ICE on the original test for pr87993:

% gfc pr87993.f90
f951: internal compiler error: Segmentation fault: 11

This test compiles under lldb. Note that the test in the test suite compiles.

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
  2021-05-19 17:16 ` [Bug fortran/100683] " jrfsousa at gcc dot gnu.org
  2021-05-31 10:51 ` dominiq at lps dot ens.fr
@ 2021-05-31 15:44 ` dominiq at lps dot ens.fr
  2021-05-31 17:18 ` dominiq at lps dot ens.fr
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-05-31 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Using an instrumented compiler I get

% gfcg pr87993.f90
../../work/libiberty/splay-tree.c:496:19: runtime error: member access within
misaligned address 0x000100000001 for type 'struct splay_tree_s', which
requires 8 byte alignment
0x000100000001: note: pointer points here
<memory cannot be printed>
../../work/libiberty/splay-tree.c:501:11: runtime error: member access within
misaligned address 0x301000007feedfa for type 'struct splay_tree_node_s', which
requires 8 byte alignment
0x301000007feedfa: note: pointer points here
<memory cannot be printed>
f951: internal compiler error: Segmentation fault: 11

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-05-31 15:44 ` dominiq at lps dot ens.fr
@ 2021-05-31 17:18 ` dominiq at lps dot ens.fr
  2021-06-13  2:11 ` jrfsousa at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-05-31 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Sorry I didn't use the right compiler. If I do so, I get

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=EXC_I386_GPFLT)
    frame #0: 0x0000000101443613 f951`splay_tree_min(sp=0x0000000100000001) at
splay-tree.c:501:11
   498    if (!n)
   499      return NULL;
   500  
-> 501    while (n->left)
   502      n = n->left;
   503  
   504    return n;
Target 0: (f951) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=EXC_I386_GPFLT)
  * frame #0: 0x0000000101443613 f951`splay_tree_min(sp=0x0000000100000001) at
splay-tree.c:501:11
    frame #1: 0x000000010002048e f951`gfc_constructor_first(base=<unavailable>)
at constructor.c:234:45
    frame #2: 0x00000001000064d3 f951`::expand_constructor(base=<unavailable>)
at array.c:1790:34
    frame #3: 0x0000000100008176 f951`gfc_expand_constructor(gfc_expr*, bool)
at array.c:1852:27
    frame #4: 0x00000001000080f5
f951`gfc_expand_constructor(e=0x0000000144505af0, fatal=<unavailable>) at
array.c:1875
    frame #5: 0x00000001000c339f f951`gfc_resolve_expr(gfc_expr*) (.part.0) at
resolve.c:7144:29
    frame #6: 0x00000001000435ea f951`::find_inquiry_ref(p=<unavailable>,
newp=0x00007ffeefbfe268) at expr.c:1778:20
    frame #7: 0x0000000100047056
f951`::simplify_ref_chain(ref=0x0000000144505ea0, type=0, p=0x00007ffeefbfe2a8)
at expr.c:2029:26
    frame #8: 0x00000001000464be f951`gfc_simplify_expr(gfc_expr*, int) at
expr.c:2268:31
    frame #9: 0x0000000100046e2d
f951`::simplify_parameter_variable(p=0x00000001445049b0, type=0) at
expr.c:2112:25
    frame #10: 0x0000000100046bd1 f951`gfc_simplify_expr(gfc_expr*, int) at
expr.c:2055:3
    frame #11: 0x00000001000b4c74 f951`gfc_match_varspec(gfc_expr*, int, bool,
bool) at primary.c:2421:22
    frame #12: 0x00000001000b6bf7
f951`gfc_match_rvalue(result=0x00007ffeefbfe598) at primary.c:3590:29
    frame #13: 0x0000000100080218 f951`::match_mult_operand(gfc_expr **) at
matchexp.c:157:24
    frame #14: 0x0000000100080200 f951`::match_mult_operand(gfc_expr **) at
matchexp.c:211
    frame #15: 0x0000000100080200
f951`::match_mult_operand(result=0x00007ffeefbfe660) at matchexp.c:267
    frame #16: 0x000000010008055d
f951`::match_add_operand(result=0x00007ffeefbfe6c8) at matchexp.c:356:26
    frame #17: 0x000000010008083e
f951`::match_level_2(result=0x00007ffeefbfe740) at matchexp.c:480:27
    frame #18: 0x0000000100080a1d
f951`::match_level_3(result=0x00007ffeefbfe7c0) at matchexp.c:551:21
    frame #19: 0x0000000100080b66 f951`::match_and_operand(gfc_expr **) at
matchexp.c:599:21
    frame #20: 0x0000000100080b5c 
> This test compiles under lldb.

f951`::match_and_operand(result=0x00007ffeefbfe840) at matchexp.c:693
    frame #21: 0x0000000100080d9d
f951`::match_or_operand(result=0x00007ffeefbfe8c0) at matchexp.c:722:25
    frame #22: 0x0000000100080ebd
f951`::match_equiv_operand(result=0x00007ffeefbfe940) at matchexp.c:765:24
    frame #23: 0x0000000100080fdd
f951`::match_level_5(result=0x00007ffeefbfe990) at matchexp.c:811:27
    frame #24: 0x0000000100080047
f951`gfc_match_expr(result=0x00007ffeefbfea28) at matchexp.c:870:21
    frame #25: 0x0000000100049368
f951`gfc_match_init_expr(result=0x00007ffeefbfeaa0) at expr.c:3130:22
    frame #26: 0x000000010003259b f951`gfc_match_data_decl() at decl.c:2884:28
    frame #27: 0x00000001000a3d12 f951`::decode_statement() at parse.c:65:15
    frame #28: 0x00000001000a3d0d f951`::decode_statement() at parse.c:376
    frame #29: 0x00000001000a9195 f951`next_statement() at parse.c:1321:27
    frame #30: 0x00000001000ab91c f951`parse_spec(gfc_statement) at
parse.c:3981:27
    frame #31: 0x00000001000aeaf4 f951`::parse_progunit(st=ST_NONE) at
parse.c:5918:19
    frame #32: 0x00000001000b06de f951`gfc_parse_file() at parse.c:6459:22
    frame #33: 0x00000001001052ac f951`gfc_be_parse_file() at f95-lang.c:212:18
    frame #34: 0x0000000100ec4df4 f951`::compile_file() at toplev.c:457:25
    frame #35: 0x000000010168c17f f951`toplev::main(int, char**) at
toplev.c:2203:24
    frame #36: 0x000000010168e411 f951`main(argc=2, argv=0x00007ffeefbff0c8) at
main.c:39:23

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-05-31 17:18 ` dominiq at lps dot ens.fr
@ 2021-06-13  2:11 ` jrfsousa at gcc dot gnu.org
  2021-06-13 16:24 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-06-13  2:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> ---
I am having trouble reproducing this.

Can you provide some more detail on your setup?

Best regards,
José Rui

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-06-13  2:11 ` jrfsousa at gcc dot gnu.org
@ 2021-06-13 16:24 ` dominiq at lps dot ens.fr
  2021-06-14 16:08 ` jrfsousa at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-06-13 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Can you provide some more detail on your setup?

program p
   integer, parameter :: a(2) = 1
   integer, parameter :: b = a(2)%kind
end

I get the ICE with a patched master and a genuine GCC11 with only the patch at
https://gcc.gnu.org/pipermail/fortran/2021-May/056053.html.

COLLECT_GCC=gfc11
COLLECT_LTO_WRAPPER=/opt/gcc/gcc11w/libexec/gcc/x86_64-apple-darwin20.5.0/11.1.1/lto-wrapper
Target: x86_64-apple-darwin20.5.0
Configured with: ../11_work/configure --prefix=/opt/gcc/gcc11w
--enable-languages=c,c++,d,fortran,ada,lto,objc,obj-c++ --with-gmp=/opt/mp
--with-isl=/opt/mp --enable-plugin
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
--with-as=/opt/mp/bin/as
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.1.1 20210612 [revision r11-8563-gf9cc49ecebfap1] (GCC) 

or

COLLECT_GCC=gfc
COLLECT_LTO_WRAPPER=/opt/gcc/gcc12w/libexec/gcc/x86_64-apple-darwin20.5.0/12.0.0/lto-wrapper
Target: x86_64-apple-darwin20.5.0
Configured with: ../work/configure --prefix=/opt/gcc/gcc12w
--enable-languages=c,c++,d,fortran,ada,lto,objc,obj-c++ --with-gmp=/opt/mp
--with-isl=/opt/mp --enable-plugin
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
--with-as=/opt/mp/bin/as
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210612 (experimental) [master revision
r12-1403-gc4e50e500da7p14] (GCC)

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-06-13 16:24 ` dominiq at lps dot ens.fr
@ 2021-06-14 16:08 ` jrfsousa at gcc dot gnu.org
  2021-06-14 16:13 ` jrfsousa at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-06-14 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> ---
I was using pr87993.f90 from the testsuite... ;-)

The fix is simple enough:

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index a37ad66..a9518e7 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -7138,8 +7138,10 @@ gfc_resolve_expr (gfc_expr *e)
       /* Also try to expand a constructor.  */
       if (t)
        {
+         gfc_simplify_expr(e, 1);
          gfc_expression_rank (e);
-         if (gfc_is_constant_expr (e) || gfc_is_expandable_expr (e))
+         if (e->expr_type == EXPR_ARRAY
+             && (gfc_is_constant_expr (e) || gfc_is_expandable_expr (e)))
            gfc_expand_constructor (e, false);
        }

I really should have though of this possibility...

Thank you very much.

Best regards,
José Rui

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-06-14 16:08 ` jrfsousa at gcc dot gnu.org
@ 2021-06-14 16:13 ` jrfsousa at gcc dot gnu.org
  2021-06-14 16:14 ` jrfsousa at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-06-14 16:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> ---
Corrected patch posted:

https://gcc.gnu.org/pipermail/fortran/2021-June/056160.html

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-06-14 16:13 ` jrfsousa at gcc dot gnu.org
@ 2021-06-14 16:14 ` jrfsousa at gcc dot gnu.org
  2021-06-17 20:27 ` jrfsousa at gcc dot gnu.org
  2021-06-17 20:28 ` jrfsousa at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-06-14 16:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> ---
Created attachment 51010
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51010&action=edit
Patch and changelog

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-06-14 16:14 ` jrfsousa at gcc dot gnu.org
@ 2021-06-17 20:27 ` jrfsousa at gcc dot gnu.org
  2021-06-17 20:28 ` jrfsousa at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-06-17 20:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> ---
Second and hopefully last update...

https://gcc.gnu.org/pipermail/fortran/2021-June/056170.html

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

* [Bug fortran/100683] Array initialization refuses valid
  2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2021-06-17 20:27 ` jrfsousa at gcc dot gnu.org
@ 2021-06-17 20:28 ` jrfsousa at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jrfsousa at gcc dot gnu.org @ 2021-06-17 20:28 UTC (permalink / raw)
  To: gcc-bugs

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

José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #51010|0                           |1
        is obsolete|                            |

--- Comment #11 from José Rui Faustino de Sousa <jrfsousa at gcc dot gnu.org> ---
Created attachment 51032
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51032&action=edit
Updated patch.

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

end of thread, other threads:[~2021-06-17 20:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 15:23 [Bug fortran/100683] New: Array initialization refuses valid jrfsousa at gcc dot gnu.org
2021-05-19 17:16 ` [Bug fortran/100683] " jrfsousa at gcc dot gnu.org
2021-05-31 10:51 ` dominiq at lps dot ens.fr
2021-05-31 15:44 ` dominiq at lps dot ens.fr
2021-05-31 17:18 ` dominiq at lps dot ens.fr
2021-06-13  2:11 ` jrfsousa at gcc dot gnu.org
2021-06-13 16:24 ` dominiq at lps dot ens.fr
2021-06-14 16:08 ` jrfsousa at gcc dot gnu.org
2021-06-14 16:13 ` jrfsousa at gcc dot gnu.org
2021-06-14 16:14 ` jrfsousa at gcc dot gnu.org
2021-06-17 20:27 ` jrfsousa at gcc dot gnu.org
2021-06-17 20:28 ` jrfsousa 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).