This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
* Re: gcc c++ bug
- To: gcc-bugs at gcc dot gnu dot org
- Subject: * Re: gcc c++ bug
- From: David Durham <david dot durham at wcom dot com>
- Date: Tue, 24 Jul 2001 13:51:03 -0500
Well... this doesn't seem right at all... The 'array' size and type of
the data-members in a class or struct are known at compile time. The
work around I've done for now is to declare an static instance, 'r', of
the struct I'm working with and then use 'sizeof(r.field)'
I propose that this be an extension of the compiler and/or get propose a
change to the standard or something...
It's quite a useful feature...
Additionally, gcc ( <=2.95.3 ) (and Sun's C++ compiler) let you take the
address of 'foo::field' and it'll give you the ( 1 based for some
reason) byte offset of that data-member in the struct. This too is a
very useful feature.
I assume the problem occurs when 'field' is preceded by 'foo::' which
looks like a reference to a static member... Is there however another
way of refering to 'field' in the context of 'foo' that would allow one
to get the size of that array without acutally declaring an instance of
the struct/class?
Thanks,
Davy
On Mon, Jul 23, 2001 at 05:53:01PM -0500, David Durham wrote:
> struct foo
> {
> char field[25];
> static int getSize()
> {
> return(sizeof(field));
> }
> };
Nope, can't do that. GCC 2.9x was not quite conformant in these
matters.
> Is there something about ANSI
> C99 and the fact that arrays can have non-constant sizes or something?
C99 has nothing to do with C++98, you know.
Phil