This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/71568] New: Inexplicable error: "X is inaccessible within this context" for a public member


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

            Bug ID: 71568
           Summary: Inexplicable error: "X is inaccessible within this
                    context" for a public member
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richardg.work at gmail dot com
  Target Milestone: ---

Created attachment 38717
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38717&action=edit
Demonstration of the error & a possible workaround

The attached 90 line test.cpp fails to compile with an inexplicable error
message :  "X is inaccessible within this context".  The X is clearly a public
member, so this is not a C++ private memeber issue.  Critically, the same code
compiles without issue on the clang compiler (clang 3.7.1)

Note : Compile test.cpp with -std=c++14.

I've seen this error in unrelated template code before, but this time I've been
able to simplify it to a 90 line repro.  

Godbolt demonstrating the error : https://godbolt.org/g/Z4hDez

/tmp/gcc-explorer-compiler116517-85-12v5300/example.cpp: In instantiation of
'struct has_nlog_custom<std::tuple<Foo0>, void>':
35 : required by substitution of 'template<class Head> typename
std::enable_if<has_nlog_custom<Head>::value, void>::type write(NLogger&, const
Head&) [with Head = std::tuple<Foo0>]'
70 : required from 'typename std::enable_if<(!
has_nlog_custom<Head>::value)>::type log(NLogger&, const Head&) [with Head =
LogStructN; typename std::enable_if<(! has_nlog_custom<Head>::value)>::type =
void]'
88 : required from here
21 : error: 'void Foo0::nlog_custom(NLogger&) const' is inaccessible within
this context
struct has_nlog_custom<T, void_t<decltype( &T::nlog_custom )>> : std::true_type
{};
^~
78 : note: declared here
void nlog_custom(NLogger & nl) const {}
^~~~~~~~~~~
21 : error: 'void Foo0::nlog_custom(NLogger&) const' is inaccessible within
this context
struct has_nlog_custom<T, void_t<decltype( &T::nlog_custom )>> : std::true_type
{};
^~
78 : note: declared here
void nlog_custom(NLogger & nl) const {}
^~~~~~~~~~~
Compilation failed


I have a workaround, changing the #if between 0 & 1 toggles the error.  But I
don't believe that I've found the root cause of the issue.  It would be very
helpful to either diagnose this as a gcc bug, or have gcc provide more
diagnostic information on the root cause.

Thanks

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]