This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
anonymous struct
- From: Patrik Weiskircher <pat at icore dot at>
- To: gcc-bugs at gcc dot gnu dot org
- Cc: Pekka Riikonen <priikone at silcnet dot org>
- Date: Sun, 24 Aug 2003 16:50:28 +0200
- Subject: anonymous struct
Hello,
I don't know if I found a bug or it should behave like that.
If you try to compile the attached file using
g++ foo.cpp -o foo
it gives you the error message:
foo.cpp:9: error: non-local function `<anonymous struct>* fe::fee()'
uses anonymous type
I tried compiling this file with Borland C++ 5.5.1, Intel C++ 7.1 and
Forte Developer 7 and it worked with all of them.
It works too if I change the
"typedef struct {"
to a
"typedef struct _Foo {"
I tested with gcc 2.95.4, gcc 3.2 and gcc 3.3.2 20030812 (Debian
prerelease) and the error appears in all of them.
Is this the correct behaviour or is it a bug in gcc?
And please include me in CC, as I'm not subscribed to the list.
Thank you,
Patrik
typedef struct {
int fee;
} *Foo;
class fe {
public:
fe();
~fe();
Foo fee() { return f; }
private:
Foo f;
};
int main()
{
Foo f;
}