public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv
@ 2005-04-04 21:59 eabaltz at sophont dot net
  2005-04-04 22:00 ` [Bug c/20760] " eabaltz at sophont dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: eabaltz at sophont dot net @ 2005-04-04 21:59 UTC (permalink / raw)
  To: gcc-bugs

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)

-- 
           Summary: cast to variable-length array type combined with switch
                    statement gives segv
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: eabaltz at sophont dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20760


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/20760] cast to variable-length array type combined with switch statement gives segv
  2005-04-04 21:59 [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv eabaltz at sophont dot net
@ 2005-04-04 22:00 ` eabaltz at sophont dot net
  2005-04-04 23:26 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: eabaltz at sophont dot net @ 2005-04-04 22:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From eabaltz at sophont dot net  2005-04-04 22:00 -------
Created an attachment (id=8533)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8533&action=view)
preprocessed source

Preprocessed source file illustrating the bug.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20760


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/20760] cast to variable-length array type combined with switch statement gives segv
  2005-04-04 21:59 [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv eabaltz at sophont dot net
  2005-04-04 22:00 ` [Bug c/20760] " eabaltz at sophont dot net
@ 2005-04-04 23:26 ` pinskia at gcc dot gnu dot org
  2005-04-05 20:50 ` jsm28 at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-04 23:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-04 23:25 -------
<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.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|cast to variable-length     |cast to variable-length
                   |array type combined with    |array type combined with
                   |switch statement gives segv |switch statement gives segv


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20760


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/20760] cast to variable-length array type combined with switch statement gives segv
  2005-04-04 21:59 [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv eabaltz at sophont dot net
  2005-04-04 22:00 ` [Bug c/20760] " eabaltz at sophont dot net
  2005-04-04 23:26 ` pinskia at gcc dot gnu dot org
@ 2005-04-05 20:50 ` jsm28 at gcc dot gnu dot org
  2005-06-01 10:23 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2005-04-05 20:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm28 at gcc dot gnu dot org  2005-04-05 20:50 -------
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.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |16989
              nThis|                            |
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-04-05 20:50:04
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20760


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/20760] cast to variable-length array type combined with switch statement gives segv
  2005-04-04 21:59 [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv eabaltz at sophont dot net
                   ` (2 preceding siblings ...)
  2005-04-05 20:50 ` jsm28 at gcc dot gnu dot org
@ 2005-06-01 10:23 ` cvs-commit at gcc dot gnu dot org
  2005-06-01 10:36 ` cvs-commit at gcc dot gnu dot org
  2005-06-01 18:59 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-01 10:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-01 10:23 -------
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



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20760


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/20760] cast to variable-length array type combined with switch statement gives segv
  2005-04-04 21:59 [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv eabaltz at sophont dot net
                   ` (3 preceding siblings ...)
  2005-06-01 10:23 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-01 10:36 ` cvs-commit at gcc dot gnu dot org
  2005-06-01 18:59 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-01 10:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-01 10:36 -------
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



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20760


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/20760] cast to variable-length array type combined with switch statement gives segv
  2005-04-04 21:59 [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv eabaltz at sophont dot net
                   ` (4 preceding siblings ...)
  2005-06-01 10:36 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-01 18:59 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-01 18:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-01 18:59 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20760


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-06-01 18:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-04 21:59 [Bug c/20760] New: cast to variable-length array type combined with switch statement gives segv eabaltz at sophont dot net
2005-04-04 22:00 ` [Bug c/20760] " eabaltz at sophont dot net
2005-04-04 23:26 ` pinskia at gcc dot gnu dot org
2005-04-05 20:50 ` jsm28 at gcc dot gnu dot org
2005-06-01 10:23 ` cvs-commit at gcc dot gnu dot org
2005-06-01 10:36 ` cvs-commit at gcc dot gnu dot org
2005-06-01 18:59 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).