This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Does GCC 3.4 fix this bug?
- From: Oliver Kullmann <O dot Kullmann at Swansea dot ac dot uk>
- To: Eljay Love-Jensen <eljay at adobe dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 11 Sep 2003 17:37:05 +0100
- Subject: Re: Does GCC 3.4 fix this bug?
- References: <5.2.1.1.0.20030911110503.00bb5d20@iplan-mn.corp.adobe.com>
Hi,
that's no bug, but the ambiguity in the syntax of C++ regarding declarations and
definitions (which is always resolved as taking the declaration):
Bar quux(Foo());
**declares** a function named quux of type
Bar ()(Foo (*)())
as the error message
test11092003.cpp:22: request for member `print' in `quux(Foo (*)())', which is
of non-aggregate type `Bar ()(Foo (*)())'
clearly states (think about it(!)). Fortunately, double brackets are not allowed
in a declaration of a function, but are allowed around expressions, which
disambiguates the line
Bar quux(Foo());
via
Bar quux((Foo()));
(and it becomes a declaration of a variable quux of type Bar, using the
one (conversion) constructor in class Bar).
Oliver
P.S. I guess that's a type in
Bar quux((0,Foo()));
?
>
> Hi everyone,
>
> Does anyone know if this annoying bug in GCC is going to be fixed in 3.4?
> --------8<--------
> class Foo
> {
> public:
> Foo();
> };
>
> Foo::Foo()
> {
> }
>
> class Bar
> {
> public:
> Bar(const Foo& foo) { }
> void print() { }
> };
>
> int main()
> {
> Bar quux(Foo()); // -- Bug in GCC 3.2 & 3.3
> //Bar quux((0,Foo())); // -- workaround in GCC 3.2 & 3.3
> quux.print();
> }
> --------8<--------
>
> (Or if GCC 3.2/3.3 are correct, let me know that I'm mistaken about the ISO 14882 standard.)
>
> Thanks,
> --Eljay
>