public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14603] New: constructors within constructor fails
@ 2004-03-16 13:14 bjorn at fiskbil dot org
2004-03-16 13:22 ` [Bug c++/14603] " pcarlini at suse dot de
2004-03-16 14:54 ` bangerth at dealii dot org
0 siblings, 2 replies; 3+ messages in thread
From: bjorn at fiskbil dot org @ 2004-03-16 13:14 UTC (permalink / raw)
To: gcc-bugs
When trying to call a constructor with two constructors, the two constructors
are called with indexed arrays, in it g++ refuses to compile it. It works if I
create variables outside of the first constructor and pass them in. Instead of
rambling I'll just show you the code and the errors.
class Vector {
public:
Vector() {}
Vector(float x, float y, float z) { coords[0]=x; coords[1]=y; coords[2]=z; }
private:
float coords[3];
};
class Model {
public:
Model() {}
Model(const Vector &m, const Vector &n) { M=m; N=n; }
private:
Vector M, N;
};
int main(int argc, char **argv) {
float v1[3], v2[3];
Model m(Vector(v1[0],v1[1],v1[2]), Vector(v2[0],v2[1],v2[2]));
return 0;
}
And the output from g++ -v -save-temps testcase.cpp is this:
# g++ -v -save-temps testcase.cppu
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,ob
jc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib -
-enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gn
u --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib,gtk --enable-objc
-gc i486-linux
Thread model: posix
gcc version 3.3.3 (Debian 20040314)
/usr/lib/gcc-lib/i486-linux/3.3.3/cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=
3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D_GNU_SOURCE testcase.cpp testcase
.ii
ignoring nonexistent directory "/usr/i486-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.3
/usr/include/c++/3.3/i486-linux
/usr/include/c++/3.3/backward
/usr/local/include
/usr/lib/gcc-lib/i486-linux/3.3.3/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i486-linux/3.3.3/cc1plus -fpreprocessed testcase.ii -quiet -du
mpbase testcase.cpp -auxbase testcase -version -o testcase.s
GNU C++ version 3.3.3 (Debian 20040314) (i486-linux)
compiled by GNU C version 3.3.3 (Debian 20040314).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64354
testcase.cpp: In function `int main(int, char**)':
testcase.cpp:29: error: parse error before `,' token
testcase.cpp:29: error: no matching function for call to `Model::Model(float&,
float&, float&)'
testcase.cpp:12: error: candidates are: Model::Model(const Model&)
testcase.cpp:15: error: Model::Model(const Vector&, const
Vector&)
testcase.cpp:14: error: Model::Model()
testcase.cpp:29: error: parse error before `)' token
This is on debian unstable with gcc 3.3.3
The same error occurs on a Red Hat 8.0 gcc 3.2 box.
Lines such as this one works though
float v1x, v1y, v1z;
Model m(Vector(v1x,v1y,v1z), Vector(v2[0],v2[1],v2[2]));
or this one
Vector v(v1[0], v1[1], v2[2]);
Model m(v, Vector(v2[0],v2[1],v2[2]));
--
Summary: constructors within constructor fails
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bjorn at fiskbil dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14603
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/14603] constructors within constructor fails
2004-03-16 13:14 [Bug c++/14603] New: constructors within constructor fails bjorn at fiskbil dot org
@ 2004-03-16 13:22 ` pcarlini at suse dot de
2004-03-16 14:54 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: pcarlini at suse dot de @ 2004-03-16 13:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pcarlini at suse dot de 2004-03-16 13:22 -------
This problem is already fixed for the forthcoming 3.4.0, thanks to a new
hand-written parser.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14603
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/14603] constructors within constructor fails
2004-03-16 13:14 [Bug c++/14603] New: constructors within constructor fails bjorn at fiskbil dot org
2004-03-16 13:22 ` [Bug c++/14603] " pcarlini at suse dot de
@ 2004-03-16 14:54 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2004-03-16 14:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-03-16 14:54 -------
Indeed. Please check out
http://gcc.gnu.org/bugs.html
This is a duplicate of many other bugs.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Known to fail| |3.3.4
Known to work| |3.4.0
Resolution| |FIXED
Target Milestone|--- |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14603
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-03-16 14:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-16 13:14 [Bug c++/14603] New: constructors within constructor fails bjorn at fiskbil dot org
2004-03-16 13:22 ` [Bug c++/14603] " pcarlini at suse dot de
2004-03-16 14:54 ` bangerth at dealii 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).