This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Does GCC 3.4 fix this bug?


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
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]