public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94897] New: range-for produces a variable initialiser with use of a forward decl.
@ 2020-04-30 20:48 iains at gcc dot gnu.org
  2020-04-30 20:49 ` [Bug c++/94897] " iains at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2020-04-30 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94897
           Summary: range-for produces a variable initialiser with use of
                    a forward decl.
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iains at gcc dot gnu.org
  Target Milestone: ---

It seems that parser.c:cp_convert_range_for () is not implementing the lowering
that its header comment outlines.

for this:
#include <array>

void
foo ()
{
  const std::array<int, 5> expectedValues = {{0, 3, 1, 4, 2}};

  for (int expectedValue : expectedValues) {
    ;
  }
}

we are getting the statement tree below, the key being (V = Var decl, Va =
artificial var decl) where the first entry initialiser contains a forward ref.

----

 V int expectedValue = E (std::array<int, E <cst>5>::value_type)E *VD
foo::__for_begin;
 Va const std::array<int, E <cst>5>& __for_range = E (const std::array<int, E
<cst>5>&)E &foo::expectedValues;
 Va const std::array<int, E <cst>5>::value_type* __for_begin;
 Va const std::array<int, E <cst>5>::value_type* __for_end;

=====

FD foo () 

- <STATEMENT_LIST>{
  S BIND_EXPR [scope 0x10399a3c0] BLOCK #0 not outer [ao] 0x0 
    [super-ctx] 0x0 SUBBLOCKS 0x10399a360
  VARS {
    V const std::array<int, E <cst>5>expectedValues = {E CE {E <cst>0, E
<cst>3, E <cst>1, E <cst>4, E <cst>2}};
  }
  BODY {
    - <STATEMENT_LIST>{
      CPs<<sD const std::array<int, E <cst>5>expectedValues = {E CE {E <cst>0,
E <cst>3, E <cst>1, E <cst>4, E <cst>2}}; CPE>>
      S BIND_EXPR [scope 0x10399a360] BLOCK #0 not outer [ao] 0x0 
        [super-ctx] 0x10399a3c0 SUBBLOCKS 0x0
      VARS {
        V int expectedValue = E (std::array<int, E <cst>5>::value_type)E *VD
foo::__for_begin;
        Va const std::array<int, E <cst>5>& __for_range = E (const
std::array<int, E <cst>5>&)E &foo::expectedValues;
        Va const std::array<int, E <cst>5>::value_type* __for_begin;
        Va const std::array<int, E <cst>5>::value_type* __for_end;
      }
      BODY {
        - <STATEMENT_LIST>{
          sD const std::array<int, E <cst>5>& __for_range = E (const
std::array<int, E <cst>5>&)E &foo::expectedValues;
          sD const std::array<int, E <cst>5>::value_type* __for_begin;
          CPs<<S xE (void)E foo::__for_begin = 
foo::__for_range.std::array<int, E <cst>5>::begin (); CPE>>
          sD const std::array<int, E <cst>5>::value_type* __for_end;
          CPs<<S xE (void)E foo::__for_end =  foo::__for_range.std::array<int,
E <cst>5>::end (); CPE>>
          sS for (; E CE foo::__for_begin != foo::__for_end; CPe<<E (void)E CE
++foo::__for_begin CPE>>)
             sD int expectedValue = E (std::array<int, E <cst>5>::value_type)E
*VD foo::__for_begin;
        }
      }
    }
  }

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

* [Bug c++/94897] range-for produces a variable initialiser with use of a forward decl.
  2020-04-30 20:48 [Bug c++/94897] New: range-for produces a variable initialiser with use of a forward decl iains at gcc dot gnu.org
@ 2020-04-30 20:49 ` iains at gcc dot gnu.org
  2021-04-27 11:38 ` jakub at gcc dot gnu.org
  2021-07-28  7:04 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2020-04-30 20:49 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.0
   Last reconfirmed|                            |2020-04-30

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

* [Bug c++/94897] range-for produces a variable initialiser with use of a forward decl.
  2020-04-30 20:48 [Bug c++/94897] New: range-for produces a variable initialiser with use of a forward decl iains at gcc dot gnu.org
  2020-04-30 20:49 ` [Bug c++/94897] " iains at gcc dot gnu.org
@ 2021-04-27 11:38 ` jakub at gcc dot gnu.org
  2021-07-28  7:04 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-27 11:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.0                        |11.2

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.1 has been released, retargeting bugs to GCC 11.2.

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

* [Bug c++/94897] range-for produces a variable initialiser with use of a forward decl.
  2020-04-30 20:48 [Bug c++/94897] New: range-for produces a variable initialiser with use of a forward decl iains at gcc dot gnu.org
  2020-04-30 20:49 ` [Bug c++/94897] " iains at gcc dot gnu.org
  2021-04-27 11:38 ` jakub at gcc dot gnu.org
@ 2021-07-28  7:04 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:04 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |---

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

end of thread, other threads:[~2021-07-28  7:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 20:48 [Bug c++/94897] New: range-for produces a variable initialiser with use of a forward decl iains at gcc dot gnu.org
2020-04-30 20:49 ` [Bug c++/94897] " iains at gcc dot gnu.org
2021-04-27 11:38 ` jakub at gcc dot gnu.org
2021-07-28  7:04 ` rguenth 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).