public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33972] New: Cannot declare operator() using function typedef
@ 2007-11-01 15:06 zweije at xs4all dot nl
2007-12-02 22:26 ` [Bug c++/33972] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: zweije at xs4all dot nl @ 2007-11-01 15:06 UTC (permalink / raw)
To: gcc-bugs
g++ rejects the following operator() declaration:
$cat bug.cpp
struct s
{
typedef void f(void);
f operator();
};
$g++ -c bug.cpp
+ exec /usr/bin/g++ -c bug.cpp
bug.cpp:4: error: declaration of 'operator()' as non-function
$g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 20071014 (prerelease) (Debian 4.2.2-3)
$
According to my reading of the c++ standard (second edition, 2003-10-15),
this is valid c++. First of all how the operator function is declared:
13.5 Overloaded operators [over.oper]
1 A function declaration having one of the following
/operator-function-id/s as its name declares an /operator
function/. An operator function is said to /implement/ the operator
named in its /operator-function-id/. [... lists operator()]
The construction above declares operator(), but is it a function
declaration? Since function declaration is not italicized, I take it
to mean any form of declaration that declares a function, not just the
syntactic form that uses the explicit argument list. The standard allows
such a member declaration:
9.3 Member functions [class.mfct]
9 [/Note:/ a member function can be declared (but not defined) using
a typedef for a function type. The resulting member function has
exactly the same type as it would have if the function declarator
were provided explicitly, see 8.3.5. [...]
I'm taking member functions to subsume member operators...
A note about class template member functions supports my view, as it
explicitly forbids the declaration when f is a template argument, but
not otherwise:
14.3.1 Template type arguments [temp.arg.type]
3 If a declaration acquires a function type through a type dependent
on a /template-parameter/ and this causes a declaration that does
not use the syntactic form of a function declarator to have function
type, the program is ill-formed. [...]
Note also that this paragraph talks about "the syntactic form of a
function declarator", suggesting that there might be other forms of
declaring a function.
Thanks.
--
Summary: Cannot declare operator() using function typedef
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zweije at xs4all dot nl
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33972
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/33972] Cannot declare operator() using function typedef
2007-11-01 15:06 [Bug c++/33972] New: Cannot declare operator() using function typedef zweije at xs4all dot nl
@ 2007-12-02 22:26 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-12-02 22:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-12-02 22:26 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2007-12-02 22:26:22
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33972
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-12-02 22:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-01 15:06 [Bug c++/33972] New: Cannot declare operator() using function typedef zweije at xs4all dot nl
2007-12-02 22:26 ` [Bug c++/33972] " pinskia at gcc dot gnu dot 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).