public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13452] New: No error on invalid (I think) C++ code
@ 2003-12-19 19:28 ian at airs dot com
2003-12-23 18:33 ` [Bug c++/13452] " pinskia at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: ian at airs dot com @ 2003-12-19 19:28 UTC (permalink / raw)
To: gcc-bugs
This code is compiled without error in the current mainline:
class C { public: template<typename i> int (*f())() const; };
However, it now seems to me that there should be an error on the trailing const.
Otherwise, I have no idea what the trailing const means. It appears that
generating a const method (i.e., a method for which `this' is a pointer to
const) requires
class C { public: template<typename i> int (*f() const)(); };
This may be a misunderstanding on my part, but at least some people share my
misunderstanding; see PR c++/13447.
--
Summary: No error on invalid (I think) C++ code
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13452
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13452] No error on invalid (I think) C++ code
2003-12-19 19:28 [Bug c++/13452] New: No error on invalid (I think) C++ code ian at airs dot com
@ 2003-12-23 18:33 ` pinskia at gcc dot gnu dot org
2004-01-12 16:11 ` Rainer dot Bensch at rsd dot rohde-schwarz dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-23 18:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-12-23 18:22 -------
Confirmed but not a regression.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-12-23 18:22:24
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13452
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13452] No error on invalid (I think) C++ code
2003-12-19 19:28 [Bug c++/13452] New: No error on invalid (I think) C++ code ian at airs dot com
2003-12-23 18:33 ` [Bug c++/13452] " pinskia at gcc dot gnu dot org
@ 2004-01-12 16:11 ` Rainer dot Bensch at rsd dot rohde-schwarz dot com
2004-01-12 16:27 ` ian at airs dot com
2005-05-25 1:11 ` ian at airs dot com
3 siblings, 0 replies; 7+ messages in thread
From: Rainer dot Bensch at rsd dot rohde-schwarz dot com @ 2004-01-12 16:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Rainer dot Bensch at rsd dot rohde-schwarz dot com 2004-01-12 16:10 -------
(In reply to comment #0)
> However, it now seems to me that there should be an error on the trailing
const.
No.
> Otherwise, I have no idea what the trailing const means. It appears that
> generating a const method (i.e., a method for which `this' is a pointer to
> const) requires
> class C { public: template<typename i> int (*f() const)(); };
> This may be a misunderstanding on my part, but at least some people share my
> misunderstanding; see PR c++/13447.
You declared a non const member function f() which returns a pointer to a const
member function. If the const is inside the parenteses, you declare a const
member function f() which returns a pointer to a non const member function.
Now, consider to place const at both...
Cheers, Rainer
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13452
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13452] No error on invalid (I think) C++ code
2003-12-19 19:28 [Bug c++/13452] New: No error on invalid (I think) C++ code ian at airs dot com
2003-12-23 18:33 ` [Bug c++/13452] " pinskia at gcc dot gnu dot org
2004-01-12 16:11 ` Rainer dot Bensch at rsd dot rohde-schwarz dot com
@ 2004-01-12 16:27 ` ian at airs dot com
2005-05-25 1:11 ` ian at airs dot com
3 siblings, 0 replies; 7+ messages in thread
From: ian at airs dot com @ 2004-01-12 16:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ian at airs dot com 2004-01-12 16:27 -------
Subject: Re: No error on invalid (I think) C++ code
"Rainer dot Bensch at rsd dot rohde-schwarz dot com" <gcc-bugzilla@gcc.gnu.org> writes:
> You declared a non const member function f() which returns a pointer to a const
> member function. If the const is inside the parenteses, you declare a const
> member function f() which returns a pointer to a non const member function.
> Now, consider to place const at both...
I don't agree. The function f() does not return a pointer to any sort
of member function. It returns a simple pointer to function.
Consider this test case:
extern int bar();
class C { public: int (*f())() const; };
int (*C::f())() const { return bar; }
Right now this compiles without error. But the `const' in the
declaration of C::f() is meaningless. C::f() returns an ordinary
function. I certainly can't declare `extern int bar() const'.
Conversely, this test case:
class C { public: int (*f())() const; int bar(); };
int (*C::f())() const { return C::bar; }
fails, with:
foo3.cc:2: error: argument of type `int (C::)()' does not match `int (*)()
Similarly, this one:
class C { public: int (*f())() const; int bar() const; };
int (*C::f())() const { return C::bar; }
fails with:
foo3.cc:2: error: argument of type `int (C::)() const' does not match `int (*)()'
(both these error messages are mildly bogus, since the case here is
not an argument mismatch, but a return mismatch, but that is a
separate issue).
So I still think that the trailing const is meaningless, and should
cause an error.
Ian
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13452
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13452] No error on invalid (I think) C++ code
2003-12-19 19:28 [Bug c++/13452] New: No error on invalid (I think) C++ code ian at airs dot com
` (2 preceding siblings ...)
2004-01-12 16:27 ` ian at airs dot com
@ 2005-05-25 1:11 ` ian at airs dot com
3 siblings, 0 replies; 7+ messages in thread
From: ian at airs dot com @ 2005-05-25 1:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ian at airs dot com 2005-05-25 00:33 -------
Just a note that this still fails to issue an error on mainline.
--
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2003-12-23 18:22:24 |2005-05-25 00:33:19
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13452
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13452] No error on invalid (I think) C++ code
[not found] <bug-13452-4@http.gcc.gnu.org/bugzilla/>
2013-04-09 17:16 ` paolo.carlini at oracle dot com
@ 2013-06-16 16:14 ` paolo.carlini at oracle dot com
1 sibling, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-16 16:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13452
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mark at halcy0n dot com
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 26143 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/13452] No error on invalid (I think) C++ code
[not found] <bug-13452-4@http.gcc.gnu.org/bugzilla/>
@ 2013-04-09 17:16 ` paolo.carlini at oracle dot com
2013-06-16 16:14 ` paolo.carlini at oracle dot com
1 sibling, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-09 17:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13452
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |witmer at averagesoftware
| |dot org
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-04-09 17:15:57 UTC ---
*** Bug 37885 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-06-16 16:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-19 19:28 [Bug c++/13452] New: No error on invalid (I think) C++ code ian at airs dot com
2003-12-23 18:33 ` [Bug c++/13452] " pinskia at gcc dot gnu dot org
2004-01-12 16:11 ` Rainer dot Bensch at rsd dot rohde-schwarz dot com
2004-01-12 16:27 ` ian at airs dot com
2005-05-25 1:11 ` ian at airs dot com
[not found] <bug-13452-4@http.gcc.gnu.org/bugzilla/>
2013-04-09 17:16 ` paolo.carlini at oracle dot com
2013-06-16 16:14 ` paolo.carlini at oracle dot com
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).