This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: C++ static integer class constants...
- From: "Ernest L. Williams Jr." <ernesto at ornl dot gov>
- To: John Ratliff <webmaster at technoplaza dot net>
- Cc: 'MSX to GCC' <gcc-help at gcc dot gnu dot org>
- Date: Tue, 18 Oct 2005 07:04:37 -0400
- Subject: RE: C++ static integer class constants...
- References: <0IOJ0024ULK8BF@emroute1.cind.ornl.gov>
On Tue, 2005-10-18 at 01:19 -0500, John Ratliff wrote:
> > * John Ratliff:
> >
> > > On comp.lang.c++, Victor Bazarov says my example program is well-formed
> > > standard C++ according to the ISO C++ standard.
> > >
> > > "Since their address is never taken, the 'foo::A' and 'foo::B' are, in
> > > fact, compile-time constant expressions that do not require storage.
> > > The objects, therefore, don't need to be defined outside of the class
> > > definition.
> >
> > This analysis argues from the implementation, not from the standard.
> >
> > The standard requires that you provide a definition if you use the
> > constant in a place which does not *require* a constant expression.
> > In other words,
> >
> > int foo[Class::static_const_member];
> >
> > is fine without a definition, but
> >
> > int bar = Class::static_const_member;
> >
> > is not.
> >
> > It's strange and smells like a mistake in the standard.
>
> In response to my message on comp.lang.c++, Greg Comeau replies
>
> "That's what it says but isn't what it meant. What it meant is what Victor
> said, and hence it was acknowledged as a defect since requiring the
> definition in all cases was not the intent when member constants were
> allowed."
>
> So, it seems that it is a mistake in the standard. For anyone who doesn't
> know him, Greg Comeau is a member of the C++ standards committee.
>
> I think g++ is trying to do the correct thing (according to the intent of
> the committee), even in 3.3, but has one problem area. I am going to leave
> out my definitions for now since it will compile on both 3.3 and 3.4 now
> that I've removed the ternary expression.
This is very important and should be sent to the GCC developers' mailing
list so that they can toss this around a bit. Do you subscribe there as
well?
Thanks,
Ernesto
>
> --John Ratliff
>
>
>