This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly
- From: "matthew_bugzilla at datadeliverance dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jul 2004 12:41:48 -0000
- Subject: [Bug c++/16347] New: Some cases of calling constructor with temporary object still not recognised properly
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This seems to be a manifestation of the problem documented as resolved in the
3.4 series compilers: if you try to create an object and pass in a temporary
object as a parameter, it still sometimes parses it as a function prototype,
even though parameter(s) are being passed to the constructor of the temporary
object. This seems to happen only if you pass a variable to the temporary
object's constructor, not if you pass a literal. The workarounds for the
original manifestation of these bugs in the pre-3.4 compilers seem to fix this
one also.
Simple example below:
------------------------------
class A
{
public:
A(int);
};
class B
{
public:
B(A);
int val;
};
main()
{
int i;
//B b(A(1)); // This works ok
//B b((A(i))); // This works too
B b(A(i)); // This doesn't
b.val = 2;
}
------------------------------------
Output of g++:
$ /usr/local/gcc-3.5-20040627/bin/g++ -v foo2.cpp
Reading specs from /usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/specs
Configured with: /usr/local/src/gcc-3.5-20040627/configure
--prefix=/usr/local/gcc-3.5-20040627
Thread model: posix
gcc version 3.5.0 20040627 (experimental)
/usr/local/gcc-3.5-20040627/libexec/gcc/i686-pc-linux-gnu/3.5.0/cc1plus -quiet
-v -D_GNU_SOURCE foo2.cpp -quiet -dumpbase foo2.cpp -mtune=pentiumpro -auxbase
foo2 -version -o /tmp/cc2cbynF.s
ignoring nonexistent directory
"/usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../include/c++/3.5.0
/usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../include/c++/3.5.0/i686-pc-linux-gnu
/usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/../../../../include/c++/3.5.0/backward
/usr/local/include
/usr/local/gcc-3.5-20040627/include
/usr/local/gcc-3.5-20040627/lib/gcc/i686-pc-linux-gnu/3.5.0/include
/usr/include
End of search list.
GNU C++ version 3.5.0 20040627 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.5.0 20040627 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
foo2.cpp: In function `int main()':
foo2.cpp:21: error: request for member `val' in `b', which is of non-class type
`B ()(A)'
--
Summary: Some cases of calling constructor with temporary object
still not recognised properly
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matthew_bugzilla at datadeliverance dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16347