From 4108536129035524380
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,add62e0f5e586127
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-09-20 01:12:08 PST
Path: bga.com!news.sprintlink.net!howland.reston.ans.net!agate!overload.lbl.gov!lll-winken.llnl.gov!fnnews.fnal.gov!fsgm01.fnal.gov!not-for-mail
From: b91926@fsgm01.fnal.gov (David Sachs)
Newsgroups: comp.std.c++
Subject: Re: compile time consts
Date: 19 Sep 1994 10:14:33 -0500
Organization: FERMILAB, Batavia, IL
Lines: 17
Message-ID: <35k9sp$irv@fsgm01.fnal.gov>
References: <1994Sep19.110228.3591@fmrco.uucp>
NNTP-Posting-Host: fsgm01.fnal.gov

dcb@lovat.fmrco.com (David Binderman) writes:

>Hello there,

>I claim the following is legal code. Three compilers disagree with me. 
>Who is correct ?

>#include <math.h>

>const int N = 1000;
>const int Q = (int) sqrt( (double) N);
>int a[ Q];

Your code is incorrect. With most compilers, Q cannot be
evaluated at compile time, because its value involves a
call to a library routine, sqrt. Therefore the compiler
cannot determine the size of array a.


