This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static const double pi = 3.1415;


On Wednesday, February 19, 2003, at 08:52 AM, Nathan Sidwell wrote:
Mike Stump wrote:
Personally, I don't find
int i = 1;
to be substantially different from:
double i = 1;
:-(  As far as extensions go, I've seen worse.
you also have to extend the meaning of a constant-expression. [9.4.2]

Seems like I am just too radical for ya'll:


static const double d = 3.1415;

int main() {
        foo(d);
}

I asked my C compiler, it like it, it knew what it meant, it knew how to optimize it, it _liked_ it, and until we make that an error... I don't think C++ should be radically different, anyway, I've already agreed with Gaby that the better forum is the C++ committee, and I'm content to not push the issue here. I've already yelped, and that's all I'm gonna do.

says
that the initializer for a static int member must be a constant integral
expression. To allow float you'd have to define what a constant float
expression is, and that'd mean you'd have to define how to do float
arithmetic at compile time. Not that any of that is insurmountable,
but you need to define it.

The above C program seemed to work in C++ as well. Either, that is a bug in C and C++, or somewhere, it is defined well enough to work.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]