This is the mail archive of the gcc-bugs@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]

[Bug c++/17061] New: 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.


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".

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

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)'
------- Additional Comments From andrei dot mischenko at mail dot ru  2004-08-17 09:40 -------
Fix:
//instead of
A a(int(x));
//one should use one of the following
A a((int)x);
A a = A(int(x));

-- 
           Summary: 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.
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrei dot mischenko at mail dot ru
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17061


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