This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12288] New: "expected function-definition" error compiling constructor
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Sep 2003 17:30:37 -0000
- Subject: [Bug c++/12288] New: "expected function-definition" error compiling constructor
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12288
Summary: "expected function-definition" error compiling
constructor
Product: gcc
Version: 3.4
Status: UNCONFIRMED
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
GCC host triplet: i386-unknown-freebsd4.8
The code below fails to compile with CVS g++ from 20030826 (I would have used a
more recent build but I can't bootstrap right now). This code compiles without
error on Comeau. The GCC config info, code and error follow:
$ g++3 -v
Reading specs from
/data/development/jw/gcc3/bin/../lib/gcc/i386-unknown-freebsd4.8/3.4/specs
Configured with: /home/jw/src/cvs/gcc/configure --prefix=/home/jw/gcc3/
--enable-languages=c,c++ --enable-concept-checks --enable-libstdcxx-pch :
(reconfigured) /home/jw/src/cvs/gcc/configure --prefix=/home/jw/gcc3/
--enable-languages=c,c++ --enable-concept-checks --enable-libstdcxx-pch :
(reconfigured)
Thread model: posix
gcc version 3.4 20030826 (experimental)
$ cat gcc_bug.cc
#include <map>
struct Foo {};
typedef std::multimap<unsigned short,Foo> FooMap;
class SameFoo
{
public:
explicit SameFoo(const FooMap::data_type& lhs) : m_arg(lhs) {}
private:
const Foo& m_arg;
};
$ g++3 gcc_bug.cc
gcc_bug.cc:10: error: ISO C++ forbids declaration of `SameFoo' with no type
gcc_bug.cc:10: error: only declarations of constructors can be `explicit'
gcc_bug.cc:10: error: expected function-definition