This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33805] New: Static member of the class should be able to depend on classes size
- From: "yuri at tsoft dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Oct 2007 22:39:24 -0000
- Subject: [Bug c++/33805] New: Static member of the class should be able to depend on classes size
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I got this error and this made me thinking.
First example produces an error:
m.C:2: error: invalid application of 'sizeof' to incomplete type 'B'
But the second one doesn't.
Why if I take sizeof() of the current class when instantiating the object it's
an error and if I pass the type to the class A as a template parameter this
isn't an error. And class A can do with it's template parameter all it wants
and this is ok.
I think first example should compile w/out errors since static object doesn't
even change the size of B, so it shouldn't matter what it is.
---- this code produces an error ----
template<int i> struct A { };
struct B { static A<sizeof(B)> a; };
---- this code compiles w/out errors ----
template<typename O> struct A { };
struct B { static A<B> a; };
--
Summary: Static member of the class should be able to depend on
classes size
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yuri at tsoft dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33805