------- Comment #8 from joseph at codesourcery dot com 2006-01-15 23:52 ------- Subject: Re: [4.0/4.1/4.2 Regression] Internal compiler error (segfault) instead of error message
On Sun, 8 Jan 2006, steven at gcc dot gnu dot org wrote: > My hack-around is to deal with label_context_stack_vm==NULL in more places. > Sadly I have no idea what this variable is for, and Joseph did not add any > comment or documentation of any form for these global variables. The documentation is on the structure definition c_label_context_vm (and similarly c_label_context_se). I think fixing pushdecl not to call c_begin_vm_scope if current_scope == file_scope should suffice. > If there is a way to reject this non-constant _before_ we call > c_begin_vm_scope, that would be the "right" fix AFAICT. The right fix there would perhaps be in grokdeclarator, if (TREE_CODE (size) == INTEGER_CST) { constant_expression_warning (size); if (tree_int_cst_sgn (size) < 0) { error ("size of array %qs is negative", name); size = integer_one_node; } } else { /* Make sure the array size remains visibly nonconstant even if it is (eg) a const variable with known value. */ size_varies = 1; before the "else" have an "else if" case that checks for NORMAL or FIELD at file scope, gives an error and uses integer_one_node instead. This should also cause certain other cases we silently accept to be unconditionally rejected instead: int a; int (*b)[(__SIZE_TYPE__)&a]; (ICEs at present because of this bug, older GCC accepts silently) or int a; struct s { int b[(__SIZE_TYPE__)&a]; }; or int a; struct s { int (*x)[(__SIZE_TYPE__)&a]; }; That way we don't rely on variable_size to give an error (it's not a good place to do so anyway, this error belongs in the front end), which won't work for TREE_CONSTANT cases such as these addresses. (All examples including the original test ((int) changed to (__SIZE_TYPE__)) should of course be added as testcases.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25161