[cfe-dev] clang bug: constant array size is recognized as variable array size
Eli Friedman
eli.friedman at gmail.com
Tue May 27 19:53:59 PDT 2008
On Tue, May 27, 2008 at 12:36 PM, Mike Stump <mrs at apple.com> wrote:
> [#10] An implementation may accept other forms of constant
> expressions.
That doesn't apply to integer constant expressions. See
http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_312.htm.
>> "(unsigned int)(100.*120.)" isn't an integer
>> constant expression (per the definition in C99 6.6), so A is in fact
>> an illegal VLA per the standard. Not sure what to do here.
>
> If one can do FP math at compile time, an error is needlessly pedantic.
If we implement rounding modes, the result of FP math is no longer constant.
And actually, in certain edge cases involving null pointer constants
and conditionals, treating an expression that isn't an integer
constant expression as an integer constant expression can lead to
errors on valid code.
By the way, this is gcc bug 456
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=456).
-Eli
More information about the cfe-dev
mailing list