public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function
@ 2011-03-11 17:27 cgd at google dot com
2011-03-11 17:38 ` [Bug c++/48078] " redi at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: cgd at google dot com @ 2011-03-11 17:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
Summary: gcc accepts-invalid: taking address of private member
function from template function
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: cgd@google.com
test case (created by Bill Clarke):
class A {
public:
A() {}
private:
void APrivateMethod() { }
};
// Enable this to get a (correct) compiler error.
#if 0
void CallAPrivateMethod() {
void (A::*fn)() = &A::APrivateMethod;
A a;
(a.*fn)();
}
#endif
template <typename T>
void CallAPrivateMethodTemplate() {
void (A::*fn)() = &A::APrivateMethod;
A a;
(a.*fn)();
}
void CallAPrivateMethodViaTemplate() {
CallAPrivateMethodTemplate<int>();
}
compiles successfully (incorrectly AFAIU) with pre-4.6 (4.6.0 20110311)
(I tested some versions of GCC back to 4.2.x, same problem. They had local
mods, but none that should have caused a difference in this regard.)
FYI, clang C++ front-end flags an error as expected:
devtools/cpp_tests/x.cc:22:24: error: 'APrivateMethod' is a private member of
'A'
void (A::*fn)() = &A::APrivateMethod;
^
devtools/cpp_tests/x.cc:8:7: note: declared private here
void APrivateMethod() { }
^
1 error generated.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] gcc accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
@ 2011-03-11 17:38 ` redi at gcc dot gnu.org
2011-03-11 18:07 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-11 17:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-11 17:38:17 UTC ---
Access checking inside templates seems to be completely broken, see PR 47346
and the bugs I listed there, this could be a dup of one of them
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] gcc accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
2011-03-11 17:38 ` [Bug c++/48078] " redi at gcc dot gnu.org
@ 2011-03-11 18:07 ` redi at gcc dot gnu.org
2011-03-11 19:59 ` cgd at google dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-11 18:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.03.11 18:07:13
Ever Confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-11 18:07:13 UTC ---
I think this is different enough from any of those others to count as a
distinct bug - confirmed
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] gcc accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
2011-03-11 17:38 ` [Bug c++/48078] " redi at gcc dot gnu.org
2011-03-11 18:07 ` redi at gcc dot gnu.org
@ 2011-03-11 19:59 ` cgd at google dot com
2011-05-11 10:52 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cgd at google dot com @ 2011-03-11 19:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
--- Comment #3 from Chris Demetriou <cgd at google dot com> 2011-03-11 19:59:40 UTC ---
(In reply to comment #2)
> I think this is different enough from any of those others to count as a
> distinct bug - confirmed
I hadn't seen them when i filed this (didn't match the searches that I did),
but yeah, looking at them I agree.
(BTW, re: the test case: Bill Clarke works for Google so it should be
adequately assigned to the FSF already.)
Thanks!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] gcc accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
` (2 preceding siblings ...)
2011-03-11 19:59 ` cgd at google dot com
@ 2011-05-11 10:52 ` redi at gcc dot gnu.org
2011-05-27 15:23 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-11 10:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-11 10:35:28 UTC ---
I've just hit another variation of this bug myself.
Reduced:
class F {
void f();
};
template<typename>
void b() {
(void) &F::f;
}
template void b<int>();
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] gcc accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
` (3 preceding siblings ...)
2011-05-11 10:52 ` redi at gcc dot gnu.org
@ 2011-05-27 15:23 ` redi at gcc dot gnu.org
2021-08-04 5:45 ` [Bug c++/48078] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-27 15:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-27 15:11:29 UTC ---
This bug is probably the reason why g++ only rejects half of the testcase for
http://llvm.org/bugs/show_bug.cgi?id=8058
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
` (4 preceding siblings ...)
2011-05-27 15:23 ` redi at gcc dot gnu.org
@ 2021-08-04 5:45 ` pinskia at gcc dot gnu.org
2021-08-04 5:47 ` pinskia at gcc dot gnu.org
2021-08-04 11:40 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 5:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=41437
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This seems fixed in GCC 11+, maybe by the patch which fixed PR 41437.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
` (5 preceding siblings ...)
2021-08-04 5:45 ` [Bug c++/48078] " pinskia at gcc dot gnu.org
@ 2021-08-04 5:47 ` pinskia at gcc dot gnu.org
2021-08-04 11:40 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 5:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |awise.gcc.bug at gmail dot com
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 70984 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/48078] accepts-invalid: taking address of private member function from template function
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
` (6 preceding siblings ...)
2021-08-04 5:47 ` pinskia at gcc dot gnu.org
@ 2021-08-04 11:40 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-04 11:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48078
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #7)
> This seems fixed in GCC 11+, maybe by the patch which fixed PR 41437.
Yes, GCC started to reject it with r11-1350
*** This bug has been marked as a duplicate of bug 41437 ***
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-08-04 11:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 17:27 [Bug c++/48078] New: gcc accepts-invalid: taking address of private member function from template function cgd at google dot com
2011-03-11 17:38 ` [Bug c++/48078] " redi at gcc dot gnu.org
2011-03-11 18:07 ` redi at gcc dot gnu.org
2011-03-11 19:59 ` cgd at google dot com
2011-05-11 10:52 ` redi at gcc dot gnu.org
2011-05-27 15:23 ` redi at gcc dot gnu.org
2021-08-04 5:45 ` [Bug c++/48078] " pinskia at gcc dot gnu.org
2021-08-04 5:47 ` pinskia at gcc dot gnu.org
2021-08-04 11:40 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).