public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gcc-bugs at marehr dot dialup.fu-berlin.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/100205] New: [11 Regression] error: invalid use of non-static data member
Date: Thu, 22 Apr 2021 11:15:21 +0000	[thread overview]
Message-ID: <bug-100205-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 100205
           Summary: [11 Regression] error: invalid use of non-static data
                    member
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de
  Target Milestone: ---

Hi gcc-team,

the following code compiles with gcc-10, but does not compile with gcc-11 any
more:

```cpp
#include <ranges>

struct coordinate_matrix {
  using index_t = size_t;
  struct convert_to_matrix_coordinate {
    index_t column_id;
    index_t operator()(index_t) { return column_id; }
  };
  using iota_view_t = decltype(std::views::iota(0, 1));
  index_t column_id;

  // does not work
  using value_type =
      decltype(std::declval<iota_view_t>() |
std::views::transform(convert_to_matrix_coordinate{column_id}));

  // does not work
  using value_type2 =
      decltype(std::views::transform(std::declval<iota_view_t>(),
convert_to_matrix_coordinate{column_id}));

  // does work
  using value_type3 =
      decltype(std::views::transform(std::declval<iota_view_t>(),
                                     ([](index_t)
                                     {
                                         return [](index_t) -> index_t
                                         {
                                             return 0;
                                         };
                                     })(column_id)));

  // does work
  using value_type4 =
      decltype(std::views::transform(std::declval<iota_view_t>(),
convert_to_matrix_coordinate{0u}));

  // does work
  using value_type5 = decltype(column_id);
};

int main()
{
    // works:
    using index_t = size_t;
    auto view = std::views::iota(0, 1);
    using iota_view_t = decltype(std::views::iota(0, 1));
    index_t column_id = 0;
    view |
std::views::transform(coordinate_matrix::convert_to_matrix_coordinate{column_id});
    using value_type = decltype(std::declval<iota_view_t>() |
                
std::views::transform(coordinate_matrix::convert_to_matrix_coordinate{column_id}));
}
```

https://godbolt.org/z/EPoP3jvab

with the following error:

```
<source>:14:97: error: invalid use of non-static data member
'coordinate_matrix::column_id'
   14 |       decltype(std::declval<iota_view_t>() |
std::views::transform(convert_to_matrix_coordinate{column_id}));
      |                                                                        
                        ^~~~~~~~~
<source>:10:11: note: declared here
   10 |   index_t column_id;
      |           ^~~~~~~~~
```

I know how to work around this, but I'm a bit confused why in some cases it
allows using column_id and some cases don't.

Thank you!

             reply	other threads:[~2021-04-22 11:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 11:15 gcc-bugs at marehr dot dialup.fu-berlin.de [this message]
2021-04-22 11:27 ` [Bug c++/100205] " rguenth at gcc dot gnu.org
2021-04-22 11:32 ` gcc-bugs at marehr dot dialup.fu-berlin.de
2021-04-22 11:41 ` gcc-bugs at marehr dot dialup.fu-berlin.de
2021-04-22 11:41 ` rguenth at gcc dot gnu.org
2021-04-22 11:46 ` [Bug c++/100205] [11/12 " redi at gcc dot gnu.org
2021-04-22 11:51 ` redi at gcc dot gnu.org
2021-04-22 11:51 ` redi at gcc dot gnu.org
2021-04-22 12:03 ` rguenth at gcc dot gnu.org
2021-04-27 11:40 ` jakub at gcc dot gnu.org
2021-05-18 16:14 ` jason at gcc dot gnu.org
2021-05-18 19:45 ` cvs-commit at gcc dot gnu.org
2021-05-18 20:05 ` gcc-bugs at marehr dot dialup.fu-berlin.de
2021-05-18 21:19 ` cvs-commit at gcc dot gnu.org
2021-05-19 20:19 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-100205-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).