Bug ID: 78609
           Summary: invalid member's visibility detection in constexpr
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot
          Reporter: bobk-off at yandex dot ru
  Target Milestone: ---

All known for me version of gcc failed to compile following code with error "
error: 'char A::data [28]' is private". clang compiles ok. Looks like compiler
incorrectly interprets members visibility.

#include <cstddef>

struct A
        char data[28];
        constexpr const char * c_str() const { return data; }

        template<size_t N> constexpr A(char const (&str)[N]) : data()
                for (size_t i=0;i<N;i++) data[i] = str[i];

        constexpr A() : data()  {};

template<size_t I>
struct B
        static const constexpr A name = A("Some text");
        static const constexpr char * value = name.c_str();

template<size_t I>
const constexpr A B<I>::name;

int main()
  volatile char d;
  const char * c = B<0>::value;
  while (*c!=0) d = *c++;  

Reply via email to