Bug 16783 - Accepts invalid integral constant expression for array size
Summary: Accepts invalid integral constant expression for array size
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
: 16711 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-07-27 13:24 UTC by Wolfgang Bangerth
Modified: 2005-01-02 01:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-10-03 18:21:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2004-07-27 13:24:11 UTC
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.
Comment 1 Wolfgang Bangerth 2004-07-27 13:25:33 UTC
*** Bug 16711 has been marked as a duplicate of this bug. ***
Comment 2 Wolfgang Bangerth 2004-07-27 13:27:19 UTC
Confirmed by jsm already. 
Comment 3 Giovanni Bajo 2004-07-31 00:28:49 UTC
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.
Comment 4 Andrew Pinski 2005-01-02 01:32:45 UTC
Fixed in 4.0.0.