c++/10621: Calling a non-qualified member function within a sizeof() expression leads to "invalid use of undefined type"
giovannibajo@libero.it
giovannibajo@libero.it
Sun May 4 15:46:00 GMT 2003
>Number: 10621
>Category: c++
>Synopsis: Calling a non-qualified member function within a sizeof() expression leads to "invalid use of undefined type"
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Sun May 04 14:56:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Giovanni Bajo
>Release: 3.3 CVS 20030503, 3.4 CVS 20030503
>Organization:
>Environment:
i686-pc-cygwin
>Description:
The following code has always been rejected by GCC:
-----------------------------------
struct Foo
{
static int func(void);
enum { value = sizeof(func()) };
};
-----------------------------------
gccbug1.cpp:5: error: invalid use of undefined type `struct Foo'
gccbug1.cpp:2: error: forward declaration of `struct Foo'
gccbug1.cpp:5: error: enumerator value for `value' not integer constant
Notice that it's possible to make the code compile simply
by qualifying the function name: sizeof(Foo::func()).
>How-To-Repeat:
Compile the above snippet
>Fix:
Qualify the function name
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list