Bug 93730 - [8/9/10 Regression] ICE in make_decl_rtl, at varasm.c:1375
Summary: [8/9/10 Regression] ICE in make_decl_rtl, at varasm.c:1375
Status: RESOLVED DUPLICATE of bug 58646
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 9.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks: C++VLA
  Show dependency tree / graph
 
Reported: 2020-02-13 10:10 UTC by Akhilesh Kumar
Modified: 2020-02-20 07:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 8.3.0
Known to fail: 10.0, 9.2.0
Last reconfirmed: 2020-02-13 00:00:00


Attachments
patch to fix this case (1.40 KB, application/mbox)
2020-02-19 06:40 UTC, Slava Barinov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Akhilesh Kumar 2020-02-13 10:10:54 UTC
Hello 

I am Getting "internal compiler error: in make_decl_rtl, at varasm.c:1375" during RTL optimization, but works fine if i pass value instead of variable name 


#g++ -c -Wno-format-truncation -Wno-narrowing MYTV/Picture.cpp -I=/usr/include/kernel-headers/ -I=/usr/include/mylog/ -I/usr/include/kernel-interfaces/ 
during RTL pass: expand
/home/user/MY/Picture.cpp:1521:13: internal compiler error: in make_decl_rtl, at varasm.c:1375
1521 |     int GammaTable[RGB_LAST][SeedCnt] = {{0,},};   /Where my seed count is 1024     
  |             ^~~~~~~~~~~~~~~~~~
	 
but code works fine if i pass direct Value in array 
  
-int GammaTable[RGB_LAST][SeedCnt] = {{0,},};        
int GammaTable[RGB_LAST][1024] = {{0,},};        
#g++ -c -Wno-format-truncation -Wno-narrowing MYTV/Picture.cpp -I=/usr/include/kernel-headers/ -I=/usr/include/mylog/ -I/usr/include/kernel-interfaces/ 
#

Unfortunately I can share Picture.cpp code 
but I am trying to reproduce this issue with some sample test application
Comment 1 Richard Biener 2020-02-13 10:44:54 UTC
Please provide a testcase.  What architecture is this on?
Comment 2 Akhilesh Kumar 2020-02-13 10:48:21 UTC
Working on Arm architecture.
I am trying to reproduce the same with sample test case
Comment 3 Akhilesh Kumar 2020-02-17 10:22:01 UTC
Please find test application to reproduce this issue 


bash-3.2# g++ -fdump-tree-all /tmp/akhilesh.cpp                                    
during RTL pass: expand
/tmp/akhilesh.cpp: In function 'int main()':
/tmp/akhilesh.cpp:4:15: internal compiler error: in make_decl_rtl, at varasm.c:1375
    4 |  unsigned int iDefaultGammaTable[3][GammaSeedCnt] = {{0,},};
      |               ^~~~~~~~~~~~~~~~~~
libbacktrace could not find executable to open

bash-3.2# cat /tmp/akhilesh.cpp 
int Seed=1024;
int main()
{
	unsigned int DefaultGammaTable[3][Seed] = {{0,},};
	return 0;
}


even same issue is reproducible with below test case also

akhilesh.k@DELL-BUILD10:~$ cat test.c 
int abc=1;
int main()
{
	int array[1][abc] ={0};  << But work well if we changes from 0 t0 1 
	return 0;
}
Comment 4 Martin Liška 2020-02-17 14:51:48 UTC
Started with r9-6851-g187c6369c0b4c7e0.
Comment 5 Martin Sebor 2020-02-17 16:35:46 UTC
Stack trace is below.  Bisecting a test case with the initializer changed to the equivalent '{ }' points to r198746 as the first revision when GCC failed with an ICE.  Prior to that, GCC rejected the code with:

  pr93730.C: error: variable-sized object ‘DefaultGammaTable’ may not be initialized
     int DefaultGammaTable[3][Seed] = {{0,},};
                                            ^
pr93730.C:4:15: warning: unused variable ‘DefaultGammaTable’ [-Wunused-variable]
    4 |  unsigned int DefaultGammaTable[3][Seed] = {{0,},};
      |               ^~~~~~~~~~~~~~~~~
during RTL pass: expand
pr93730.C:4:15: internal compiler error: in make_decl_rtl, at varasm.c:1346
    4 |  unsigned int DefaultGammaTable[3][Seed] = {{0,},};
      |               ^~~~~~~~~~~~~~~~~
0x1af7fce make_decl_rtl(tree_node*)
	/src/gcc/trunk/gcc/varasm.c:1342
0x103cc40 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/src/gcc/trunk/gcc/expr.c:10085
0x10349d2 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/src/gcc/trunk/gcc/expr.c:8353
0x10122a3 expand_expr
	/src/gcc/trunk/gcc/expr.h:282
0x104995c expr_size(tree_node*)
	/src/gcc/trunk/gcc/expr.c:12652
0x1034657 expand_constructor
	/src/gcc/trunk/gcc/expr.c:8219
0x103e351 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/src/gcc/trunk/gcc/expr.c:10383
0x10349d2 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/src/gcc/trunk/gcc/expr.c:8353
0x10297d6 store_expr(tree_node*, rtx_def*, int, bool, bool)
	/src/gcc/trunk/gcc/expr.c:5747
0x10303b1 store_field
	/src/gcc/trunk/gcc/expr.c:7219
0x1027162 expand_assignment(tree_node*, tree_node*, bool)
	/src/gcc/trunk/gcc/expr.c:5369
0xe5abf4 expand_gimple_stmt_1
	/src/gcc/trunk/gcc/cfgexpand.c:3749
0xe5b00e expand_gimple_stmt
	/src/gcc/trunk/gcc/cfgexpand.c:3847
0xe6378b expand_gimple_basic_block
	/src/gcc/trunk/gcc/cfgexpand.c:5887
0xe656c2 execute
	/src/gcc/trunk/gcc/cfgexpand.c:6542
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

*** This bug has been marked as a duplicate of bug 58646 ***
Comment 6 Slava Barinov 2020-02-19 06:40:00 UTC
Created attachment 47875 [details]
patch to fix this case

Not solution for c++/58646, but this allows to work around certain case when we want to initialize VLA with zeroes.

Bootstrapped on x86_64, no testsuite regressions found.

Not sure about mangling: is there any ABI requirements to mangling for cases from mangle72.C?
Comment 7 Martin Sebor 2020-02-19 15:07:38 UTC
I think VLA initialization should be rejected in C++ just as it is in C.

The mangling wasn't specified the last time I checked so unless there has been some informal consensus on how to do it changing it for the member pointers shouldn't be a big problem.  (They might also end up taking place as a result of the patch for pr90938 if the code gets moved from reshape_init_array_1 to process_init_constructor_array as Jason suggested.)

In any case, please post your patch (for bug 58646) for consideration to gcc-patches.