c++/10496: erroneus suggestion in diagnostic and possible bug

Gabriel Dos Reis gdr@integrable-solutions.net
Fri Apr 25 13:26:00 GMT 2003


The following reply was made to PR c++/10496; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: benko@sztaki.hu
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/10496: erroneus suggestion in diagnostic and possible bug
Date: 25 Apr 2003 15:16:24 +0200

 benko@sztaki.hu writes:
 
 [...]
 
 | arta:~/c/proba$ cat ptr2mem.cc
 | struct a
 | {
 |   int f() const;
 | };
 | 
 | 
 | int
 | a::f() const
 | {
 |   int (a::* b)() const = &a::f;
 | }
 | arta:~/c/proba$ g++3 -v
 | Reading specs from /gml/shared/gcc-3.2.3/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
 | Configured with: ../gcc-3.2.3/configure --prefix=/gml/shared/gcc-3.2.3
 | Thread model: posix
 | gcc version 3.2.3
 | arta:~/c/proba$ g++3 ptr2mem.cc
 | ptr2mem.cc: In member function `int a::f() const':
 | ptr2mem.cc:10: ISO C++ forbids taking the address of an unqualified non-static 
 |    member function to form a pointer to member function.  Say `&const a::f'
 
 Odd.
 
 | I think &f should be enough, but &const a::f
 
 No, "&f" is no good and "&const a::f" is weird and plain dead wrong.  
 "&a::f" is good.  
 
 | (as suggested by the diagnostics) is refused by g++
 | (I think rightly so).
 | 
 | (&a::f is accepted.)
 
 But isn't what you wrote in your testcase?  Sometime  is odd about it.
 
 -- Gaby



More information about the Gcc-prs mailing list