[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 --- Comment #15 from Anthony Sharp --- This should now be fixed as part of my patch: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=be246ac2d26e1cb072f205bf97d5eac150220f3f
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 Anthony Sharp changed: What|Removed |Added CC||anthonysharp15 at gmail dot com --- Comment #14 from Anthony Sharp --- I believe I accidentally fixed this in my recent PR17314 patch. These testcases now correctly say "private" instead of protected/inaccessible etc. However, I had not anticipated the use of the "using" keyword whilst making that patch, which means that the place where the error diagnostic points to in terms of where it was declared private is slightly inaccurate. I will start working on a patch for this.
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 --- Comment #13 from Jonathan Wakely --- FWIW Harald's analysis looks right to me
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 Harald van Dijk changed: What|Removed |Added CC||harald at gigawatt dot nl --- Comment #12 from Harald van Dijk --- Fabien, are you sure that the test case in comment 9 is invalid? C++11 reads "In a using-declaration used as a member-declaration, the nested-name-specifier shall name a base class of the class being defined. If such a using-declaration names a constructor, the nested-name-specifier shall name a direct base class of the class being defined; otherwise it introduces the set of declarations found by member name lookup (10.2, 3.4.3.1)." which makes sense: any inherited member, even from an indirect base class, can be introduced into the current class, except for an indirect base class's constructor. As for "It is invalid for a second reason, 'using Base::i' is declared (implicitly) in a private section, so inaccessible in DerivedDerived.", the DerivedDerived using declaration uses a fully qualified ns::Base::i, the visibility of which should depend on the visibility in Base, not the visibility in Derived. If the code used ns::Derived::i, then it would make sense to issue an error, and clang does emit an error in that case. As for being separate from this bug, a trivial change of that test case to namespace ns { class Base { protected: int i; }; class Derived : public Base { using Base::i; }; } class DerivedDerived : public ns::Derived { using ns::Base::i; }; makes GCC emit test.cc:4:9: error: ‘int ns::Base::i’ is protected int i; ^ test.cc:11:7: error: within this context class DerivedDerived : public ns::Derived { ^ which is exactly the error message that this bug is about. Similarly, changing the "protected:" to "public:" in the original test case changes the error message from "protected" to "inaccessible".
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 --- Comment #11 from Andrey Belevantsev --- (In reply to fabien from comment #10) > The testcase is not valid, as a using declaration shall refer to a direct > base class, which is not the case in 'using ns::Base::i' (the namespace ns > does not seem to be relevant here). It is invalid for a second reason, > 'using Base::i' is declared (implicitly) in a private section, so > inaccessible in DerivedDerived. Thank you for clarification, we weren't 100% sure whether this is a bug but decided in favor of it because of icc/clang results... > > > It's 9 years of the > > original bugreport, maybe rise a priority?.. > > Raising the priority would not make me fix this bug more quickly. This bug > is not a regression, and not a high priority in my opinion. Thought, it is > in my TODO list. I gave it a try two years ago, and it was not obvious to > fix. Feel free to take over if you have more free time than I have. And sorry for the noise here, I just thought that having another test would help with fixing the issue but of course the invalid test does not help.
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 --- Comment #10 from fabien at gcc dot gnu.org --- (In reply to Andrey Belevantsev from comment #9) > Another test case of the same issue (both clang and icc compile this fine): It is not the same issue as the protected keyword is not involved. (And Clang and ICC should be fixed instead, see below). > > namespace ns { > class Base { > public: > int i; > }; > class Derived : public Base { > using Base::i; > }; > } > class DerivedDerived : public ns::Derived { > using ns::Base::i; > }; > > we get > > /tmp/ns.C:4:9: error: ‘int ns::Base::i’ is inaccessible > /tmp/ns.C:10:7: error: within this context > > It is indeed rejects-valid but I cannot claim this is a regression as I > can't find the version that did that correctly. The testcase is not valid, as a using declaration shall refer to a direct base class, which is not the case in 'using ns::Base::i' (the namespace ns does not seem to be relevant here). It is invalid for a second reason, 'using Base::i' is declared (implicitly) in a private section, so inaccessible in DerivedDerived. > It's 9 years of the > original bugreport, maybe rise a priority?.. Raising the priority would not make me fix this bug more quickly. This bug is not a regression, and not a high priority in my opinion. Thought, it is in my TODO list. I gave it a try two years ago, and it was not obvious to fix. Feel free to take over if you have more free time than I have.
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 Andrey Belevantsev changed: What|Removed |Added CC||abel at gcc dot gnu.org, ||amonakov at gcc dot gnu.org --- Comment #9 from Andrey Belevantsev --- Another test case of the same issue (both clang and icc compile this fine): namespace ns { class Base { public: int i; }; class Derived : public Base { using Base::i; }; } class DerivedDerived : public ns::Derived { using ns::Base::i; }; we get /tmp/ns.C:4:9: error: ‘int ns::Base::i’ is inaccessible /tmp/ns.C:10:7: error: within this context It is indeed rejects-valid but I cannot claim this is a regression as I can't find the version that did that correctly. It's 9 years of the original bugreport, maybe rise a priority?..
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 --- Comment #8 from fabien at gcc dot gnu.org 2012-04-15 18:24:08 UTC --- (In reply to comment #7) > (In reply to comment #6) > > (In reply to comment #5) > > > You should write to Jason directly, as he is probably the only person in > > > the > > > world that understands the C++ FE well enough to answer this. > > > > > > (And am I the only one who thinks this is REALLY bad for the future of > > > g++?) > > > > I don't think it is he is only person who understands the C++ front-end, but > > rather he is one of the few who understands the C++ language fully and > > understands the interaction between different items of the C++ language. So > > please stop spreading the false hope about G++. > > I am not "spreading false hopes", that sounds like I am hoping that G++ will > fail or some such. If I wanted that, why would I be contributing my free time > to G++? > > The question above is not about C++, but about the C++ FE specifically. So, > please, tell us, who else may know the answer besides Jason AND have the time > or interest to answer? Please add them to the CC, so Fabien can fix this bug. Thanks for your interest manuel, Indeed I've asked Jason via private emails, he answers the best he can, but unfortunately, it was too late for me to solve it for 4.7. I'm targeting 4.8...
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 --- Comment #7 from Manuel López-Ibáñez 2012-04-15 17:41:02 UTC --- (In reply to comment #6) > (In reply to comment #5) > > You should write to Jason directly, as he is probably the only person in the > > world that understands the C++ FE well enough to answer this. > > > > (And am I the only one who thinks this is REALLY bad for the future of g++?) > > I don't think it is he is only person who understands the C++ front-end, but > rather he is one of the few who understands the C++ language fully and > understands the interaction between different items of the C++ language. So > please stop spreading the false hope about G++. I am not "spreading false hopes", that sounds like I am hoping that G++ will fail or some such. If I wanted that, why would I be contributing my free time to G++? The question above is not about C++, but about the C++ FE specifically. So, please, tell us, who else may know the answer besides Jason AND have the time or interest to answer? Please add them to the CC, so Fabien can fix this bug.
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 --- Comment #6 from Andrew Pinski 2012-04-15 17:17:54 UTC --- (In reply to comment #5) > You should write to Jason directly, as he is probably the only person in the > world that understands the C++ FE well enough to answer this. > > (And am I the only one who thinks this is REALLY bad for the future of g++?) I don't think it is he is only person who understands the C++ front-end, but rather he is one of the few who understands the C++ language fully and understands the interaction between different items of the C++ language. So please stop spreading the false hope about G++.
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 Manuel López-Ibáñez changed: What|Removed |Added CC||manu at gcc dot gnu.org --- Comment #5 from Manuel López-Ibáñez 2012-04-15 17:09:04 UTC --- (In reply to comment #4) > > The problem seems to be that we do not have the information that 'i' is > referenced through 'this' when checking the access in accessible_p, unless I'm > missing something. > > Any idea where to find this information ? You should write to Jason directly, as he is probably the only person in the world that understands the C++ FE well enough to answer this. (And am I the only one who thinks this is REALLY bad for the future of g++?)
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 fabien at gcc dot gnu.org changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #4 from fabien at gcc dot gnu.org 2011-11-27 21:13:49 UTC --- (In reply to comment #0) > Given this code: > > class A { > protected: > int i; > }; > > class B : public A { > private: > using A::i; > }; > > class C : public B { > public: > void f() { A::i = 0; } > }; As 'i' is referenced through 'this' and is qualified with a nested name specifier (A), I think we should perform the access lookup directly in A. The problem seems to be that we do not have the information that 'i' is referenced through 'this' when checking the access in accessible_p, unless I'm missing something. Any idea where to find this information ?
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377 fabien at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED CC||fabien at gcc dot gnu.org
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-01 03:34 --- (In reply to comment #0) > (It actually prints the message twice, but that's PR 19375) Actually it was not, it was a related case but we still get the message twice, I filed PR 21312 with a modifed testcase without the use of using. -- What|Removed |Added Last reconfirmed|2005-01-11 17:08:01 |2005-05-01 03:34:00 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
--- Additional Comments From lerdsuwa at gcc dot gnu dot org 2005-01-12 10:46 --- The bug is simply incorrect error message logic. The 'protected' comes from the point that 'A::i' is declared, not the actual access computed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377
[Bug c++/19377] Using declaration in "private" part causes "protected" diagnostic
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-11 17:08 --- No this is valid code. We don't implement full using semantics. This might be related to PR 6936. -- What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed||1 Keywords||rejects-valid Last reconfirmed|-00-00 00:00:00 |2005-01-11 17:08:01 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19377