public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97234] New: Constexpr class-scope array initializer referencing previous elements
@ 2020-09-29  1:09 botond at mozilla dot com
  2021-08-17  5:23 ` [Bug c++/97234] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: botond at mozilla dot com @ 2020-09-29  1:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97234
           Summary: Constexpr class-scope array initializer referencing
                    previous elements
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: botond at mozilla dot com
  Target Milestone: ---

The following code:

struct S {
    static constexpr int rolling_sum[4]{
        0,
        rolling_sum[0] + 1,
        rolling_sum[1] + 2,
        rolling_sum[2] + 3
    };
};

produces errors when compiled with g++ 10:

test.cpp:4:9: error: ‘rolling_sum’ was not declared in this scope
    4 |         rolling_sum[0] + 1,
      |         ^~~~~~~~~~~
test.cpp:5:9: error: ‘rolling_sum’ was not declared in this scope
    5 |         rolling_sum[1] + 2,
      |         ^~~~~~~~~~~
test.cpp:6:9: error: ‘rolling_sum’ was not declared in this scope
    6 |         rolling_sum[2] + 3
      |   

The code is accepted by clang. It's also accepted by gcc if the array is
declared at namespace scope, leading me to believe that rejecting it at class
scope is likely a bug.

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

end of thread, other threads:[~2021-08-17 19:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29  1:09 [Bug c++/97234] New: Constexpr class-scope array initializer referencing previous elements botond at mozilla dot com
2021-08-17  5:23 ` [Bug c++/97234] " pinskia at gcc dot gnu.org
2021-08-17  5:40 ` botond at mozilla dot com
2021-08-17 19:43 ` botond at mozilla dot com
2021-08-17 19:56 ` redi 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).