[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2016-03-26 Thread sasho648 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

sasho648 at gmail dot com changed:

   What|Removed |Added

Summary|VM structure type specifier |VM structure type specifier
   |in  list of parameter   |in list of parameter
   |declarations function   |declarations within nested
   |definition  |function definition ices.

--- Comment #1 from sasho648 at gmail dot com ---
Consider this self-contained example:

main() 
{
void func(int a, struct {int _[a];} v) {}
}

When compiled it Ices both on GCC 6.0 and GCC 4.8.2 .

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2016-03-26 Thread sasho648 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

--- Comment #2 from sasho648 at gmail dot com ---
Must be noted that such code must be valid and actually currently working fine
and as expected when the function is not nested. Eg.:

#include 

extern void fp(int a, const struct {int _[a];} *b)
{
for(size_t i=0; i < sizeof(b->_) / sizeof(b->_[0]); ++i)
printf("%d ", b->_[i]);

 printf("%zu\n", sizeof(b->_));
}

void f(int a, struct {int _[a];} b)
{
for(size_t i=0; i < sizeof(b._) / sizeof(b._[0]); ++i) //modify while
retaining the passed argument
b._[i] *= 9;

fp(a, &b); //prints 81 as many times as 'a'
}

main(int n, char **pp)
{
scanf("%i", &n);

struct {int _[n];} tmp;

for(int i; i < n; ++i)
tmp._[i] = 9;

((void (*)(int a, __typeof__(tmp) b))f)(n, tmp); //cast required as VM
types aren't equal in the case

fp(n, &tmp); //should print 9 as many times as 'n'
}

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2016-03-26 Thread sasho648 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

--- Comment #3 from sasho648 at gmail dot com ---
currently *is* working fine and as expected when the function is not nested

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2016-03-26 Thread sasho648 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

--- Comment #4 from sasho648 at gmail dot com ---
The full ice message is:

test_bug_0.c: In function ‘main’:
test_bug_0.c:24:1: internal compiler error: Segmentation fault
0xb482ef crash_signal
../../gcc/gcc/toplev.c:335
0xbda96a get_frame_type
../../gcc/gcc/tree-nested.c:208
0xbda96a get_chain_decl
../../gcc/gcc/tree-nested.c:314
0xbddde9 get_chain_decl
../../gcc/gcc/tree-nested.c:826
0xbddde9 get_nonlocal_debug_decl
../../gcc/gcc/tree-nested.c:830
0xbde1d8 convert_nonlocal_reference_op
../../gcc/gcc/tree-nested.c:909
0xde8ac2 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set >*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set >*))
../../gcc/gcc/tree.c:11531
0x8d6960 walk_gimple_op(gimple*, tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
../../gcc/gcc/gimple-walk.c:201
0x8d6edc walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
../../gcc/gcc/gimple-walk.c:584
0x8d70c8 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
../../gcc/gcc/gimple-walk.c:51
0x8d6f82 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
../../gcc/gcc/gimple-walk.c:594
0x8d70c8 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
../../gcc/gcc/gimple-walk.c:51
0x8d6f82 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
../../gcc/gcc/gimple-walk.c:594
0x8d70c8 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
../../gcc/gcc/gimple-walk.c:51
0xbda371 walk_body
../../gcc/gcc/tree-nested.c:573
0xbda3c8 walk_function
../../gcc/gcc/tree-nested.c:584
0xbda3c8 walk_all_functions
../../gcc/gcc/tree-nested.c:649
0xbe2562 lower_nested_functions(tree_node*)
../../gcc/gcc/tree-nested.c:3133
0x7738b6 cgraph_node::analyze()
../../gcc/gcc/cgraphunit.c:631
0x776e33 analyze_functions
../../gcc/gcc/cgraphunit.c:1086

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2016-03-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-03-29
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #5 from Marek Polacek  ---
Confirmed.  Looks similar to PR60085.

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2016-03-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

--- Comment #6 from Marek Polacek  ---
Even r104500 ICEs.  But gcc34 compiles it fine:

$ gcc34 q.c -c
q.c: In function `main':
q.c:4: warning: structure defined inside parms
q.c:4: warning: anonymous struct declared inside parameter list
q.c:4: warning: its scope is only this definition or declaration, which is
probably not what you want

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2023-05-19 Thread muecker at gwdg dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

Martin Uecker  changed:

   What|Removed |Added

 CC||muecker at gwdg dot de

--- Comment #7 from Martin Uecker  ---
*** Bug 106465 has been marked as a duplicate of this bug. ***

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2023-05-19 Thread muecker at gwdg dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

--- Comment #8 from Martin Uecker  ---
https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618911.html

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2023-05-23 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

--- Comment #9 from CVS Commits  ---
The master branch has been updated by Martin Uecker :

https://gcc.gnu.org/g:f9b5be322358ee63798e02a9103b6bbe459e7aea

commit r14-1142-gf9b5be322358ee63798e02a9103b6bbe459e7aea
Author: Martin Uecker 
Date:   Thu Apr 13 19:37:12 2023 +0200

Fix ICEs related to VM types in C 1/2 [PR70418, PR107557, PR108423]

Size expressions were sometimes lost and not gimplified correctly, leading
to
ICEs and incorrect evaluation order.  Fix this by 1) not recursing into
pointers when gimplifying parameters in the middle-end (the code is merged
with
gimplify_type_sizes), which is incorrect because it might access variables
declared later for incomplete structs, and 2) tracking size expressions for
struct/union members correctly, 3) emitting code to evaluate size
expressions
for missing cases (nested functions, empty declarations, and
structs/unions).

PR c/70418
PR c/106465
PR c/107557
PR c/108423

gcc/c/
* c-decl.cc (start_decl): Make sure size expression are
evaluated only in correct context.
(grokdeclarator): Size expression in fields may need a bind
expression, make sure DECL_EXPR is always created.
(grokfield, declspecs_add_type): Pass along size expressions.
(finish_struct): Remove unneeded DECL_EXPR.
(start_function): Evaluate size expressions for nested functions.
* c-parser.cc (c_parser_struct_declarations,
c_parser_struct_or_union_specifier): Pass along size expressions.
(c_parser_declaration_or_fndef): Evaluate size expression.
(c_parser_objc_at_property_declaration,
c_parser_objc_class_instance_variables): Adapt.
* c-tree.h (grokfield): Adapt declaration.

gcc/testsuite/
* gcc.dg/nested-vla-1.c: New test.
* gcc.dg/nested-vla-2.c: New test.
* gcc.dg/nested-vla-3.c: New test.
* gcc.dg/pr70418.c: New test.
* gcc.dg/pr106465.c: New test.
* gcc.dg/pr107557-1.c: New test.
* gcc.dg/pr107557-2.c: New test.
* gcc.dg/pr108423-1.c: New test.
* gcc.dg/pr108423-2.c: New test.
* gcc.dg/pr108423-3.c: New test.
* gcc.dg/pr108423-4.c: New test.
* gcc.dg/pr108423-5.c: New test.
* gcc.dg/pr108423-6.c: New test.
* gcc.dg/typename-vla-2.c: New test.
* gcc.dg/typename-vla-3.c: New test.
* gcc.dg/typename-vla-4.c: New test.
* gcc.misc-tests/gcov-pr85350.c: Adapt.

[Bug c/70418] VM structure type specifier in list of parameter declarations within nested function definition ices.

2023-11-03 Thread uecker at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70418

uecker at gcc dot gnu.org changed:

   What|Removed |Added

 CC||uecker at gcc dot gnu.org
 Resolution|--- |FIXED
   Target Milestone|--- |14.0
 Status|NEW |RESOLVED
  Known to fail||6.0

--- Comment #10 from uecker at gcc dot gnu.org ---
Fixed on trunk.