This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/10621: Calling a non-qualified member function within a sizeof() expression leads to "invalid use of undefined type"
- From: giovannibajo at libero dot it
- To: gcc-gnats at gcc dot gnu dot org
- Date: 4 May 2003 14:52:10 -0000
- Subject: c++/10621: Calling a non-qualified member function within a sizeof() expression leads to "invalid use of undefined type"
- Reply-to: giovannibajo at libero dot it
>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: