>Submitter-Id:  net
>Originator:    
>Organization:  
>Confidential:  no
>Synopsis:      c++ syntax analyser bug. "A a(int(x));" declares an object and 
>calls a constructor, but is parsed as if it were "A a(int x);" which declares 
>a function pointer. 
>Severity:      serious
>Priority:      medium
>Category:  c++
>Class: rejects-legal   
>Release:       3.3.3 (Debian 20040401) (Debian testing/unstable)
>Environment:
System: Linux xenon 2.6.6-perfctr-xenon #1 Wed Jun 23 19:37:00 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 
--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=gnu --enable-debug --enable-java-gc=boehm 
--enable-java-awt=xlib --enable-objc-gc i486-linux
>Description:
c++ syntax analyser bug. "A a(int(x));" declares an object and calls a cast 
operator and constructor, but is parsed as if it were "A a(int x);" which 
declares a function pointer.Thus the compiler forbids the feather legal usage 
of an object "a". 
 
>How-To-Repeat:
struct A
{
  A(int x){}
  void m(void){}
};

void f(void)
{
  double x = 5.0;
  A a(int(x));
  a.m();
}

//bug.cpp: In function `void f()':
//bug.cpp:11: error: request for member `m' in `a', which is of non-aggregate
//   type `A ()(int)'

>Fix:
//instead of
A a(int(x));
//one should use one of the following
A a((int)x);
A a = A(int(x));


Reply via email to