From -2804905195857014913
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,add62e0f5e586127
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-09-21 09:22:12 PST
Newsgroups: comp.std.c++
Path: bga.com!news.sprintlink.net!howland.reston.ans.net!EU.net!Austria.EU.net!rcvie!cett.alcatel-alsthom.fr!slsv6bt!news
From: kanze@us-es.sel.de (James Kanze US/ESC 60/3/164 #71425)
Subject: Re: compile time consts
In-Reply-To: dcb@lovat.fmrco.com's message of Mon, 19 Sep 1994 11:02:28 GMT
Message-ID: <KANZE.94Sep20183134@slsvhdt.us-es.sel.de>
Lines: 29
Sender: news@lts.sel.alcatel.de
Organization: SEL
References: <1994Sep19.110228.3591@fmrco.uucp>
Date: 20 Sep 1994 16:31:34 GMT

In article <1994Sep19.110228.3591@fmrco.uucp> dcb@lovat.fmrco.com
(David Binderman) writes:

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

Three against one.  You loose.

|> #include <math.h>

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

See section 5.19 of the ARM: "A constant-expression can involve only
literals, enumerators, const values of integral types initialized with
constant expressions, and sizeof expressions."  No function calls.  So
Q is not a constant-expression (since it is not initialized with a
constant expression).

Finally section 8.4 clearly says that the dimension specifier of the
array must be a constant expression.
-- 
James Kanze      Tel.: (+33) 88 14 49 00     email: kanze@lts.sel.alcatel.de
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
                              -- Beratung in industrieller Datenverarbeitung




