public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/21536] New: C99 array of variable length use causes segmentation fault
@ 2005-05-12 18:01 shane256 at hotmail dot com
  2005-05-12 18:05 ` [Bug c/21536] " shane256 at hotmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: shane256 at hotmail dot com @ 2005-05-12 18:01 UTC (permalink / raw)
  To: gcc-bugs

Platform: Linux GCC x86.  I have generated a test case where the code I have 
using a C99 array with variable length causes a segmentation fault.  The thing 
is, if I comment out an unrelated line of code that is impossible to be 
executed and not in the execution pathway (it's in the body of an if statement 
that can not be executed because of the conditional anyway and added to that, I 
put a return 0; in front of the line of code so if it did happen to get in 
there, it would return before executing the line of code) the segmentation 
fault does not happen.  Also, if I don't do that, but I do comment out an 
unused automatic variable defined in the main() function (which calls the test 
function), the segmentation fault does not happen.  The test code is ~40 lines 
long and contains all the temporary files requested, the version information, 
and a more detailed explanation of how to reproduce the segmentation fault.  
This is all in a tar.gz file that you can get from 
http://www.sinistershane.net/~shane/files/testcase.tar.gz

The segv appears in both x86_64 and x86 (32bit) executables.

-- 
           Summary: C99 array of variable length use causes segmentation
                    fault
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: shane256 at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c/21536] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
@ 2005-05-12 18:05 ` shane256 at hotmail dot com
  2005-05-12 18:06 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: shane256 at hotmail dot com @ 2005-05-12 18:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From shane256 at hotmail dot com  2005-05-12 18:05 -------
Created an attachment (id=8874)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8874&action=view)
Contains test case code, intermediate files, etc. demonstrating the issue


-- 


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


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

* [Bug c/21536] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
  2005-05-12 18:05 ` [Bug c/21536] " shane256 at hotmail dot com
@ 2005-05-12 18:06 ` pinskia at gcc dot gnu dot org
  2005-05-12 18:08 ` [Bug c/21536] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-12 18:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-12 18:06 -------
*** Bug 21533 has been marked as a duplicate of this bug. ***

-- 


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


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

* [Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
  2005-05-12 18:05 ` [Bug c/21536] " shane256 at hotmail dot com
  2005-05-12 18:06 ` pinskia at gcc dot gnu dot org
@ 2005-05-12 18:08 ` pinskia at gcc dot gnu dot org
  2005-05-19 17:22 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-12 18:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-12 18:07 -------
Confirmed, I really thought I saw this before.  Anyways this is a regression from 2.95.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
      Known to fail|                            |3.0.4 3.2.3 3.2.2 3.3.3
                   |                            |3.4.0 4.0.0
      Known to work|                            |2.95.3
   Last reconfirmed|0000-00-00 00:00:00         |2005-05-12 18:07:43
               date|                            |
            Summary|C99 array of variable length|[3.4/4.0/4.1 Regression] C99
                   |use causes segmentation     |array of variable length use
                   |fault                       |causes segmentation fault
   Target Milestone|---                         |3.4.4


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


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

* [Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
                   ` (2 preceding siblings ...)
  2005-05-12 18:08 ` [Bug c/21536] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-05-19 17:22 ` mmitchel at gcc dot gnu dot org
  2005-05-27 17:14 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-05-19 17:22 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.4                       |3.4.5


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


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

* [Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
                   ` (3 preceding siblings ...)
  2005-05-19 17:22 ` mmitchel at gcc dot gnu dot org
@ 2005-05-27 17:14 ` jakub at gcc dot gnu dot org
  2005-06-01 10:23 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-05-27 17:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2005-05-27 17:14 -------
I can't reproduce the segfault, but that's only because the problem manifests
as use of uninitialized variable.

/* PR c/21536 */
/* { dg-do compile } */
/* { dg-options "-O2 -Wuninitialized" } */

typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t);

void
foo (int x, int y)
{
  void *d = malloc (10 * 10 * sizeof (double));
  double (*e)[x][y] = d;
  if (x > 8)
    (*e)[x - 2][y - 2] = 0.0;
  else
    (*e)[x - 1][y - 1] = 1.0;
}

int
main ()
{
  foo (10, 10);
  return 0;
}

reproduces the problem reliably (by checking if it issued a bogus warning:
warning: '.0' is used uninitialized in this function).


-- 


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


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

* [Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
                   ` (4 preceding siblings ...)
  2005-05-27 17:14 ` jakub 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 19:00 ` [Bug c/21536] [3.4 " pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ 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 21536

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=21536


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

* [Bug c/21536] [3.4/4.0/4.1 Regression] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
                   ` (5 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 19:00 ` [Bug c/21536] [3.4 " pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ 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 21536

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=21536


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

* [Bug c/21536] [3.4 Regression] C99 array of variable length use causes segmentation fault
  2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
                   ` (6 preceding siblings ...)
  2005-06-01 10:36 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-01 19:00 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-01 19:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-01 19:00 -------
Fixed in 4.0.1 and above.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|2.95.3                      |2.95.3 4.0.1 4.1.0
            Summary|[3.4/4.0/4.1 Regression] C99|[3.4 Regression] C99 array
                   |array of variable length use|of variable length use
                   |causes segmentation fault   |causes segmentation fault


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


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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-12 18:01 [Bug c/21536] New: C99 array of variable length use causes segmentation fault shane256 at hotmail dot com
2005-05-12 18:05 ` [Bug c/21536] " shane256 at hotmail dot com
2005-05-12 18:06 ` pinskia at gcc dot gnu dot org
2005-05-12 18:08 ` [Bug c/21536] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-05-19 17:22 ` mmitchel at gcc dot gnu dot org
2005-05-27 17:14 ` jakub 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 19:00 ` [Bug c/21536] [3.4 " 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).