As stated in PR 16711, we accept this code: ---------------- int array [((int)(void*)1)]; ---------------- even though the array size is not an integral constant expression. That's odd, since we reject this expression in various other places (see PR 16711), but accept it here. We shouldn't. W.
*** Bug 16711 has been marked as a duplicate of this bug. ***
Confirmed by jsm already.
This patch of mines: 2004-03-19 Giovanni Bajo <giovannibajo@gcc.gnu.org> PR c++/14545 * parser.c (cp_parser_functional_cast): A cast to anything but integral or enumaration type is not an integral constant expression. should also handle this case. If it does not, it probably means that for some reason the expression within the braces is not being parsed as a constant expression. This strikes me as odd though, and I wonder if the extra level of parenthesis is confusing the parser somehow. There is some complex code to handle extra-level of parenthesis which are disambiguators in many situations, so it is very possible that somewhere we forget to set/propagate the constant- expression flag.
Fixed in 4.0.0.