gcc -v: Configured with: ../gcc-3.4.3/configure --prefix=/u/ki/eabaltz/usr/i386 Thread model: posix gcc version 3.4.3 command line: gcc -Wall --save-temps bug.c this works: ./a.out 1 matrix[0][]: 1.0 -2.0 -3.0 matrix[1][]: 2.0 4.0 -6.0 matrix[2][]: 3.0 6.0 9.0 matrix[0][]: 1.0 -2.0 -3.0 matrix[1][]: 2.0 4.0 -6.0 matrix[2][]: 3.0 6.0 9.0 --- this doesn't: ./a.out 2 matrix[0][]: 1.0 -2.0 -3.0 matrix[1][]: 2.0 4.0 -6.0 matrix[2][]: 3.0 6.0 9.0 Segmentation fault (core dumped)
Created attachment 8533 [details] preprocessed source Preprocessed source file illustrating the bug.
<L17>:; D.1897 = N - 1; D.1898 = (unsigned int) D.1897; N.23 = N; N.24 = (long unsigned int) N.23; D.1901 = D.1898 * N.24; D.1902 = D.1901 * 8; D.1903 = (double[0:(long unsigned int) (SAVE_EXPR <N.23> - 1)] *) D.1902; D.1904 = D.1903 + mp; param = (*D.1904)[0]; goto <bb 20> (<L19>); <L18>:; D.1905 = N - 1; D.1906 = (unsigned int) D.1905; N.25 = (long unsigned int) N.23; D.1908 = D.1906 * N.25; D.1909 = D.1908 * 8; D.1910 = (double[0:(long unsigned int) (SAVE_EXPR <N.23> - 1)] *) D.1909; D.1911 = D.1910 + mp; param = (*D.1911)[0]; See how N.23 is used in the second case but not defined.
I'd like to get rid of the use of SAVE_EXPR for VLA sizes in C, but there may well be a smaller local fix for this bug.
Subject: Bug 20760 CVSROOT: /cvs/gcc Module name: gcc Changes by: jakub@gcc.gnu.org 2005-06-01 10:23:17 Modified files: gcc : ChangeLog gimplify.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: 20050527-1.c Log message: PR c/21536 PR c/20760 * gimplify.c (gimplify_decl_expr): Call gimplify_type_sizes on variable sizes types if a decl is a pointer to a VLA. (gimplify_type_sizes): Handle POINTER_TYPE and REFERENCE_TYPE. Call gimplify_type_sizes on aggregate fields. Prevent infinite recursion. * gcc.dg/20050527-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8979&r2=2.8980 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&r1=2.129&r2=2.130 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5572&r2=1.5573 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20050527-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 20760 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: jakub@gcc.gnu.org 2005-06-01 10:35:49 Modified files: gcc : ChangeLog gimplify.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: 20050527-1.c Log message: PR c/21536 PR c/20760 * gimplify.c (gimplify_decl_expr): Call gimplify_type_sizes on variable sizes types if a decl is a pointer to a VLA. (gimplify_type_sizes): Handle POINTER_TYPE and REFERENCE_TYPE. Call gimplify_type_sizes on aggregate fields. Prevent infinite recursion. * gcc.dg/20050527-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.273&r2=2.7592.2.274 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.113.2.4&r2=2.113.2.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.216&r2=1.5084.2.217 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20050527-1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed.