This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17062] New: c++ syntax bug. Object declaration treated as a function pointer declaration.
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Aug 2004 10:33:39 -0000
- Subject: [Bug c++/17062] New: c++ syntax bug. Object declaration treated as a function pointer declaration.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
c++ syntax analyser wrongly parses "A a(B(x));" which is an object declaration with three constructor calls ( B::B(int); B(const B&); A(B); ).
This construct is treated as a function pointer declaration "A a(B x);"
Environment:
System: Linux cactus 2.6.4 #1 Tue Apr 6 11:23:53 MSD 2004 i686 GNU/Linux
Architecture: i686
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --disable-werror i486-linux
How-To-Repeat:
$ cat > bug.cpp
struct B
{
B(int x){}
};
struct A
{
A(B x){}
void m(void){}
};
void f(void)
{
int x = 0;
A a(B(x));
a.m();
}
^D
$ g++ -c bug.cpp
bug.cpp: In function `void f()':
bug.cpp:16: error: request for member `m' in `a', which is of non-class type `A ()(B)'
------- Additional Comments From andrei dot mischenko at mail dot ru 2004-08-17 10:33 -------
Fix:
replace
A a(B(x));
with either
A a((B)x);
or
A a = A(B(x));
--
Summary: c++ syntax bug. Object declaration treated as a function
pointer declaration.
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andrei dot mischenko at mail dot ru
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17062