public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96716] New: GCC reports "object is private" when it's accessed through proper accessor
@ 2020-08-19 20:36 vorfeed.canal at gmail dot com
  2020-08-20  8:06 ` [Bug c++/96716] " redi at gcc dot gnu.org
  2020-08-20  8:09 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: vorfeed.canal at gmail dot com @ 2020-08-19 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96716
           Summary: GCC reports "object is private" when it's accessed
                    through proper accessor
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vorfeed.canal at gmail dot com
  Target Milestone: ---

The following program doesn't work ( https://godbolt.org/z/87cr44 ):

#include <array>
#include <string_view>

class Foo {
 public:
  auto constexpr  getfoo() const -> std::string_view {
    return {foo.data(), 2};
  }
 private:
  const std::array<char, 3> foo = {'a', 'b', '\0'};
};

inline constexpr Foo foo;

template <typename>
class Bar {
 public:
  static constexpr auto bar = foo.getfoo();
};

auto& baz = Bar<int>::bar;

Error message:
<source>: In instantiation of 'constexpr const std::basic_string_view<char>
Bar<int>::bar':

<source>:21:23:   required from here

<source>:18:25: error: 'const std::array<char, 3> Foo::foo' is private within
this context

   18 |   static constexpr auto bar = foo.getfoo();

      |                         ^~~

<source>:10:29: note: declared private here

   10 |   const std::array<char, 3> foo = {'a', 'b', '\0'};

      |                             ^~~

Compiler returned: 1

All other compilers work fine ( https://godbolt.org/z/WvfrPf )

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

end of thread, other threads:[~2020-08-20  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 20:36 [Bug c++/96716] New: GCC reports "object is private" when it's accessed through proper accessor vorfeed.canal at gmail dot com
2020-08-20  8:06 ` [Bug c++/96716] " redi at gcc dot gnu.org
2020-08-20  8:09 ` 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).