From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1FAF1393C856; Thu, 20 Aug 2020 08:06:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FAF1393C856 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597910762; bh=ZWLHmW9MqjhmMCJ9LyzJP+4nH2UvH08jMPzdT/+bEhE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UG1VQWHCCX2qOxFnv7uyKzKIdwFDBN+033ybU+U47bwU8hq1vSyGsuNz1heeymqag iiqu/bHuiMlqvMt7mfCk6i8rol2mQ2/rU5xs2OjHA0h5OtcDLsC5Zs9tJb6kNUASYF kyhBl9ks+S4y1D1M8A+OqHDgxrHQ06cC+dVs+4KU= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96716] GCC reports "object is private" when it's accessed through proper accessor Date: Thu, 20 Aug 2020 08:06:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed keywords Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Aug 2020 08:06:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96716 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2020-08-20 Ever confirmed|0 |1 Keywords| |rejects-valid --- Comment #1 from Jonathan Wakely --- Reduced: struct string_view { constexpr string_view(const char* p) : p(p) { } const char* p; }; class Foo { public: constexpr string_view getfoo() const { return {&foo}; } private: const char foo =3D 'c'; }; inline constexpr Foo foo; template class Bar { public: static constexpr auto bar =3D foo.getfoo(); }; auto& baz =3D Bar::bar; pr96716.C: In instantiation of 'constexpr const string_view Bar::bar': pr96716.C:24:23: required from here pr96716.C:21:25: error: 'const char Foo::foo' is private within this context 21 | static constexpr auto bar =3D foo.getfoo(); | ^~~ pr96716.C:13:14: note: declared private here 13 | const char foo =3D 'c'; | ^~~=