[Bug c++/92965] New: "note: 'x' is not public" emitted even when no error is emitted

arthur.j.odwyer at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 17 02:06:00 GMT 2019


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

            Bug ID: 92965
           Summary: "note: 'x' is not public" emitted even when no error
                    is emitted
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

cat >test.cc <<EOF
template<int>
class TS {
    int x;
public:
    constexpr TS(int) {}
};
TS(int) -> TS<1>;

template<TS> void foo() {}  // #1
template<int> void foo() {}  // #2

void test() { foo<2>(); }
EOF
g++ -std=c++2a test.cc

test.cc: In function 'void test()':
test.cc:4:9: note: 'TS<1>::x' is not public
    4 |     int x;
      |         ^

What's happening here is that the compiler is attempting to substitute into foo
#1, failing because TS<1> is not a structural type, emitting the note
explaining why TS<1> is not structural, and then proceeding to try foo #2,
which works fine and therefore the original error about foo #1 is suppressed
and never emitted. So the note is just hanging out there on its own, in an
otherwise successful compile.

I assume GCC has some mechanism to push/defer diagnostics in a SFINAE context,
and the mechanism simply wasn't applied to this new note.


More information about the Gcc-bugs mailing list