[Bug c++/21762] New: Void functions can't return invocation of pointers to void member functions

donaldc at csgsolar dot com dot au gcc-bugzilla@gcc.gnu.org
Thu May 26 05:44:00 GMT 2005


Formally: The check to see if a function returns void fails when you have a
member function pointer of a class of incomplete type.

The following code fails to compile on gcc 4.0.0
This is a regression. It compiled on gcc 3.x, and 2.95
It also compiles on MSVC7,7.1,8.0, Intel (x86 + Itanium), Digital Mars, Comeau,
Metrowerks 7, Borland, Open Watcom, PGI.

Although it is an obscure bug, it is important for my 'FastDelegate' library at
CodeProject, which has become extremely popular -- a surprising number of people
are affected by this bug.

bug.cpp: In function 'void failingfunc()':
bug.cpp:13: error: return-statement with a value, in function returning 'void'
--------------------------------------
// works on gcc 3.x, and all other compilers.
// if change 'void' to 'int', it works.
// if change 'class A;' to 'class A{};', it works.

class A;

typedef void (A::*VoidMemFn)();

void failingfunc() {
	A *p;
	VoidMemFn z;
	return (p->*z)();
}

int main(void)
{
  failingfunc();
  return 0;
}

-- 
           Summary: Void functions can't return invocation of pointers to
                    void member functions
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: donaldc at csgsolar dot com dot au
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list