public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100205] New: [11 Regression] error: invalid use of non-static data member
@ 2021-04-22 11:15 gcc-bugs at marehr dot dialup.fu-berlin.de
  2021-04-22 11:27 ` [Bug c++/100205] " rguenth at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: gcc-bugs at marehr dot dialup.fu-berlin.de @ 2021-04-22 11:15 UTC (permalink / raw)
  To: gcc-bugs

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!

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

end of thread, other threads:[~2021-05-19 20:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 11:15 [Bug c++/100205] New: [11 Regression] error: invalid use of non-static data member gcc-bugs at marehr dot dialup.fu-berlin.de
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

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).