public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23194] New: Unhelpful diagnostic for incorrect pointer-to-member function syntax
@ 2005-08-02 6:38 redi at gcc dot gnu dot org
2005-08-02 6:41 ` [Bug c++/23194] " pinskia at gcc dot gnu dot org
2005-08-02 8:45 ` redi at gcc dot gnu dot org
0 siblings, 2 replies; 16+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-08-02 6:38 UTC (permalink / raw)
To: gcc-bugs
Given:
struct A {
void mf() {}
};
int main()
{
void (A::*pmf)() = &A::mf;
A a;
a.*pmf(); // should be (a.*pmf)();
}
mainline GCC says to use .* or ->* to use the PMF,
pfm_diag.cc: In function 'int main()':
pfm_diag.cc:9: error: must use '.*' or '->*' to call pointer-to-member function
in 'pmf (...)'
This is unhelpful if you don't know the right syntax, because the correct
operator _is_ present, but the compiler is complaining about the expression to
the right of the operator. Maybe it would be better if the error message had a
complete example after it:
pfm_diag.cc: In function 'int main()':
pfm_diag.cc:9: error: must use '.*' or '->*' to call pointer-to-member function
in 'pmf (...)', e.g. '(a.*f) (...)'
--
Summary: Unhelpful diagnostic for incorrect pointer-to-member
function syntax
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: redi at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
2005-08-02 6:38 [Bug c++/23194] New: Unhelpful diagnostic for incorrect pointer-to-member function syntax redi at gcc dot gnu dot org
@ 2005-08-02 6:41 ` pinskia at gcc dot gnu dot org
2005-08-02 8:45 ` redi at gcc dot gnu dot org
1 sibling, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-02 6:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-02 06:41 -------
Before 3.3, GCC gave:
t.cc:9: pointer to member function called, but not in class scope
Which is even worse.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Known to fail| |3.3 4.0.0 4.1.0 3.2.3 3.4.5
| |3.3.3 2.95.3
Last reconfirmed|0000-00-00 00:00:00 |2005-08-02 06:41:48
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
2005-08-02 6:38 [Bug c++/23194] New: Unhelpful diagnostic for incorrect pointer-to-member function syntax redi at gcc dot gnu dot org
2005-08-02 6:41 ` [Bug c++/23194] " pinskia at gcc dot gnu dot org
@ 2005-08-02 8:45 ` redi at gcc dot gnu dot org
1 sibling, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-08-02 8:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From redi at gcc dot gnu dot org 2005-08-02 08:45 -------
Ah, I didn't check further back than 3.3, thanks, Andrew.
For comparison, Comeau's online compiler doesn't give a very helpful message
either, it says that "a.*pmf" must be an expression - which is true but no more
likely to help inexpert users realise that they need parentheses.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (10 preceding siblings ...)
2008-06-24 20:45 ` redi at gcc dot gnu dot org
@ 2008-06-24 20:47 ` jwakely dot gcc at gmail dot com
11 siblings, 0 replies; 16+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2008-06-24 20:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from jwakely dot gcc at gmail dot com 2008-06-24 20:46 -------
Fixed for 4.4
--
jwakely dot gcc at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2007-10-03 0:32 ` jwakely dot gcc at gmail dot com
@ 2008-06-24 20:45 ` redi at gcc dot gnu dot org
2008-06-24 20:47 ` jwakely dot gcc at gmail dot com
11 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu dot org @ 2008-06-24 20:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from redi at gcc dot gnu dot org 2008-06-24 20:44 -------
Subject: Bug 23194
Author: redi
Date: Tue Jun 24 20:44:04 2008
New Revision: 137086
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137086
Log:
PR c++/23194
* typeck.c (cp_build_function_call): Show example syntax in
diagnostic.
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2007-10-03 0:24 ` pinskia at gcc dot gnu dot org
@ 2007-10-03 0:32 ` jwakely dot gcc at gmail dot com
2008-06-24 20:45 ` redi at gcc dot gnu dot org
2008-06-24 20:47 ` jwakely dot gcc at gmail dot com
11 siblings, 0 replies; 16+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2007-10-03 0:32 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 817 bytes --]
------- Comment #12 from jwakely dot gcc at gmail dot com 2007-10-03 00:31 -------
I'm bootstrapping mainline as of yesterday (r128908) with gcc version 4.1.2
20070626 (Red Hat 4.1.2-13)
The format I tried was:
error ("must use %<.*%> or %<->*%> to call pointer-to-member "
"function in %<%1$E (...)%>, e.g. %<(... ->* %1$E) (...)%>",
original);
and I get:
cc1: warnings being treated as errors
../../gcc-4.x/gcc/cp/typeck.c: In function build_function_call:
../../gcc-4.x/gcc/cp/typeck.c:2720: error: unknown conversion type character
1 in format
../../gcc-4.x/gcc/cp/typeck.c:2720: error: unknown conversion type character
1 in format
../../gcc-4.x/gcc/cp/typeck.c:2720: error: too many arguments for format
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2007-10-03 0:16 ` jwakely dot gcc at gmail dot com
@ 2007-10-03 0:24 ` pinskia at gcc dot gnu dot org
2007-10-03 0:32 ` jwakely dot gcc at gmail dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-10-03 0:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pinskia at gcc dot gnu dot org 2007-10-03 00:24 -------
(In reply to comment #10)
> Andrew, unfortunately that format fails with -Werror
That should work, what version of GCC are you using to compile GCC? If it does
not work, we forgot to add this formating checking to GCC itself even though we
added support for it (mostly for translations).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2007-10-03 0:03 ` bangerth at dealii dot org
@ 2007-10-03 0:16 ` jwakely dot gcc at gmail dot com
2007-10-03 0:24 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2007-10-03 0:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jwakely dot gcc at gmail dot com 2007-10-03 00:16 -------
Andrew, unfortunately that format fails with -Werror
I'm testing now, but my machine's developed a hardware problem and keeps
segfaulting, which makes it hard to build GCC let alone run the testsuite.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2007-10-03 0:00 ` jwakely dot gcc at gmail dot com
@ 2007-10-03 0:03 ` bangerth at dealii dot org
2007-10-03 0:16 ` jwakely dot gcc at gmail dot com
` (4 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: bangerth at dealii dot org @ 2007-10-03 0:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from bangerth at dealii dot org 2007-10-03 00:03 -------
Now we only need someone to test the patch and a diagnostic maintainer to
approve...
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2007-10-02 23:59 ` pinskia at gmail dot com
@ 2007-10-03 0:00 ` jwakely dot gcc at gmail dot com
2007-10-03 0:03 ` bangerth at dealii dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2007-10-03 0:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jwakely dot gcc at gmail dot com 2007-10-02 23:59 -------
Yes, it looks better with spaces, thanks.
I think ->* still looks clearer than .* even with the spaces.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
2007-10-02 23:54 ` jwakely dot gcc at gmail dot com
@ 2007-10-02 23:59 ` Andrew Pinski
0 siblings, 0 replies; 16+ messages in thread
From: Andrew Pinski @ 2007-10-02 23:59 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
On 2 Oct 2007 23:54:04 -0000, jwakely dot gcc at gmail dot com
<gcc-bugzilla@gcc.gnu.org> wrote:
> ------- Comment #6 from jwakely dot gcc at gmail dot com 2007-10-02 23:54 -------
> (From update of attachment 14287)
> >+ "function in %<%E (...)%>, e.g. %<(... ->* %E) (...)%>",
> >+ original, original);
> > return error_mark_node;
It might be better to use %$1E (I think that is how it is done) so you
don't have to pass original twice.
Thanks,
Andrew Pinski
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-10-02 23:54 ` jwakely dot gcc at gmail dot com
@ 2007-10-02 23:59 ` pinskia at gmail dot com
2007-10-03 0:00 ` jwakely dot gcc at gmail dot com
` (6 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: pinskia at gmail dot com @ 2007-10-02 23:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pinskia at gmail dot com 2007-10-02 23:59 -------
Subject: Re: Unhelpful diagnostic for incorrect pointer-to-member function
syntax
On 2 Oct 2007 23:54:04 -0000, jwakely dot gcc at gmail dot com
<gcc-bugzilla@gcc.gnu.org> wrote:
> ------- Comment #6 from jwakely dot gcc at gmail dot com 2007-10-02 23:54 -------
> (From update of attachment 14287)
> >+ "function in %<%E (...)%>, e.g. %<(... ->* %E) (...)%>",
> >+ original, original);
> > return error_mark_node;
It might be better to use %$1E (I think that is how it is done) so you
don't have to pass original twice.
Thanks,
Andrew Pinski
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-10-02 23:30 ` bangerth at dealii dot org
@ 2007-10-02 23:54 ` jwakely dot gcc at gmail dot com
2007-10-02 23:59 ` Andrew Pinski
2007-10-02 23:59 ` pinskia at gmail dot com
` (7 subsequent siblings)
11 siblings, 1 reply; 16+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2007-10-02 23:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jwakely dot gcc at gmail dot com 2007-10-02 23:54 -------
(From update of attachment 14287)
>Index: gcc/cp/typeck.c
>===================================================================
>--- gcc/cp/typeck.c (revision 128908)
>+++ gcc/cp/typeck.c (working copy)
>@@ -2716,8 +2716,8 @@
> if (TYPE_PTRMEMFUNC_P (fntype))
> {
> error ("must use %<.*%> or %<->*%> to call pointer-to-member "
>- "function in %<%E (...)%>",
>- original);
>+ "function in %<%E (...)%>, e.g. %<(... ->* %E) (...)%>",
>+ original, original);
> return error_mark_node;
> }
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
2007-10-02 22:08 ` bangerth at dealii dot org
2007-10-02 23:28 ` jwakely dot gcc at gmail dot com
@ 2007-10-02 23:30 ` bangerth at dealii dot org
2007-10-02 23:54 ` jwakely dot gcc at gmail dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: bangerth at dealii dot org @ 2007-10-02 23:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from bangerth at dealii dot org 2007-10-02 23:29 -------
(In reply to comment #4)
> I chose to use ->* not .* because otherwise you get (....*pmf) which doesn't
> help either!
You could leave a space around either of the two operators.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
2007-10-02 22:08 ` bangerth at dealii dot org
@ 2007-10-02 23:28 ` jwakely dot gcc at gmail dot com
2007-10-02 23:30 ` bangerth at dealii dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2007-10-02 23:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jwakely dot gcc at gmail dot com 2007-10-02 23:28 -------
Created an attachment (id=14287)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14287&action=view)
add example to diagnostic
This adds ", e.g. '(...->*pmf) (...)'" to the error message.
I chose to use ->* not .* because otherwise you get (....*pmf) which doesn't
help either!
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/23194] Unhelpful diagnostic for incorrect pointer-to-member function syntax
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
@ 2007-10-02 22:08 ` bangerth at dealii dot org
2007-10-02 23:28 ` jwakely dot gcc at gmail dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 16+ messages in thread
From: bangerth at dealii dot org @ 2007-10-02 22:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from bangerth at dealii dot org 2007-10-02 22:08 -------
Still present. I know I should know better, but I too ran into this knife
just now and couldn't figure out what was going on for 10 minutes before I
remembered. The error message is really not very helpful...
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Known to fail|3.3 4.0.0 4.1.0 3.2.3 3.4.5 |3.3 4.0.0 4.1.0 4.2.0 4.3.0
|3.3.3 2.95.3 |3.2.3 3.4.5 3.3.3 2.95.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23194
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2008-06-24 20:47 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-02 6:38 [Bug c++/23194] New: Unhelpful diagnostic for incorrect pointer-to-member function syntax redi at gcc dot gnu dot org
2005-08-02 6:41 ` [Bug c++/23194] " pinskia at gcc dot gnu dot org
2005-08-02 8:45 ` redi at gcc dot gnu dot org
[not found] <bug-23194-5876@http.gcc.gnu.org/bugzilla/>
2007-10-02 22:08 ` bangerth at dealii dot org
2007-10-02 23:28 ` jwakely dot gcc at gmail dot com
2007-10-02 23:30 ` bangerth at dealii dot org
2007-10-02 23:54 ` jwakely dot gcc at gmail dot com
2007-10-02 23:59 ` Andrew Pinski
2007-10-02 23:59 ` pinskia at gmail dot com
2007-10-03 0:00 ` jwakely dot gcc at gmail dot com
2007-10-03 0:03 ` bangerth at dealii dot org
2007-10-03 0:16 ` jwakely dot gcc at gmail dot com
2007-10-03 0:24 ` pinskia at gcc dot gnu dot org
2007-10-03 0:32 ` jwakely dot gcc at gmail dot com
2008-06-24 20:45 ` redi at gcc dot gnu dot org
2008-06-24 20:47 ` jwakely dot gcc at gmail 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).