Bug 22439 - [4.0/4.1 regression] ICE with char VLA and __SIZE_TYPE__ argument (so no cast)
Summary: [4.0/4.1 regression] ICE with char VLA and __SIZE_TYPE__ argument (so no cast)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.1
: P2 normal
Target Milestone: 4.0.2
Assignee: Andrew Pinski
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2005-07-12 13:05 UTC by etienne_lorrain
Modified: 2005-08-26 15:14 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.0
Known to fail: 4.0.0 4.1.0
Last reconfirmed: 2005-08-08 17:33:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description etienne_lorrain 2005-07-12 13:05:23 UTC
etienne@cygne:~/projet$ gcc fntbin2h.c
fntbin2h.c: In function 'fct':
fntbin2h.c:50: warning: passing argument 1 of 'fct2' from incompatible pointer 
type
fntbin2h.c:62: internal compiler error: in size_binop, at fold-const.c:1637
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.0/README.Bugs>.
etienne@cygne:~/projet$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-
languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --
with-system-zlib --libexecdir=/usr/lib --enable-nls --without-included-
gettext --enable-threads=posix --program-suffix=-4.0 --enable-__cxa_atexit --
enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --
enable-java-gc=boehm --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-
1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-
checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.1 20050701 (prerelease) (Debian 4.0.0-12)
etienne@cygne:~/projet$

------------------------------
/* fntbin2h.c of Gujin (see sourceforge) */
void PRINTF (char *, ...);
void fct2(unsigned char *font[256], void *ptr);

void fct (unsigned fntheigh, void *ptr)
  {
  unsigned char font[256][fntheigh];
  unsigned font_index;
  const unsigned char font_order[256] = {
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
        0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,

        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
        0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
        0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,

        0x7F,  '¹',  '²',  '³',  '¼',  '½',  '¾',  '%',
         'ª',  'º',  '°',  '·',  '.',  ':',  ',',  ';',
        '\'',  '"',  '`',  '^',  '~',  '¨',  '´',  '¸',
         '«',  '»',  '¬',  '×',  'µ',  '&',  '§',  '¶',
         '[',  ']',  '{',  '}',  '(',  ')',  '<',  '>',
         '#',  '@',  '?',  '¿',  '!',  '¡',  '¦',  '|',
         '+',  '-',  '±',  '÷',  '/', '\\',  '_',  '­',
         '¯',  '*',  '=',  '¤',  '£',  '$',  '¢',  '¥',
         '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
         '8',  '9',  ' ', 0xA0,  '®',  '©',  'Þ',  'þ', /* NBSP, big/small 
islandic thorn */

        /* Accented letter order:
                grave, acute, circumflex, tilda, trema, round */
         'A',  'À',  'Á',  'Â',  'Ã',  'Ä',  'Å',  'Æ',
         'B',  'C',  'Ç',  'D',  'Ð',  'E',  'È',  'É',
         'Ê',  'Ë',  'F',  'G',  'H',  'I',  'Ì',  'Í',
         'Î',  'Ï',  'J',  'K',  'L',  'M',  'N',  'Ñ',
         'O',  'Ò',  'Ó',  'Ô',  'Õ',  'Ö',  'Ø',  'P',
         'Q',  'R',  'S',  'ß',  'T',  'U',  'Ù',  'Ú',
         'Û',  'Ü',  'V',  'W',  'X',  'Y',  'Ý',  'Z',

         'a',  'à',  'á',  'â',  'ã',  'ä',  'å',  'æ',
         'b',  'c',  'ç',  'd',  'ð',  'e',  'è',  'é',
         'ê',  'ë',  'f',  'g',  'h',  'i',  'ì',  'í',
         'î',  'ï',  'j',  'k',  'l',  'm',  'n',  'ñ',
         'o',  'ò',  'ó',  'ô',  'õ',  'ö',  'ø',  'p',
         'q',  'r',  's',  't',  'u',  'ù',  'ú',  'û',
         'ü',  'v',  'w',  'x',  'y',  'ý',  'ÿ',  'z'
        };

  fct2 (font, ptr);
  PRINTF ("const union font_line_u font8x%u[256][%u] = {\n", fntheigh, 
fntheigh);
  for (font_index = 0; font_index < 256; font_index++) {
      unsigned cpt;
      if (   font_order[font_index] < 0x20
          || (font_order[font_index] >= 0x80 && font_order[font_index] < 0xA0))
          PRINTF ("    [0x%X] = {\n", font_order[font_index]);
        else if (font_order[font_index] == '\'' || font_order[font_index] 
== '\\')
          PRINTF ("    ['\\%c'] = {\n", font_order[font_index]);
        else
          PRINTF ("    ['%c'] = {\n", font_order[font_index]);
      for (cpt = 0; cpt < fntheigh; cpt++) {
          unsigned tmp = font[font_order[font_index]][cpt];
          PRINTF ("\t%c (%c,%c,%c,%c,%c,%c,%c,%c),\n",
//              (cpt == 0) ? 'T' : ((cpt == fntheigh - 1) ? 'B' : 'M'),
                'B',
                (tmp & 0x80)? 'X' : '_', (tmp & 0x40)? 'X' : '_',
                (tmp & 0x20)? 'X' : '_', (tmp & 0x10)? 'X' : '_',
                (tmp & 0x08)? 'X' : '_', (tmp & 0x04)? 'X' : '_',
                (tmp & 0x02)? 'X' : '_', (tmp & 0x01)? 'X' : '_');
          }
      PRINTF ("\t},\n");
      }

  PRINTF ("    }; /* font8x%u */\n", fntheigh);
  }
------------------------------

  Thanks,
  Etienne.
Comment 1 Volker Reichelt 2005-07-12 13:40:30 UTC
Confirmed. Reduced testcase:

===========================
char foo(unsigned n)
{
    char c[1][n];
    return c[0][0];
}
===========================

The ICE appeared with gcc 4.0.0.
The code compiles fine if one replaces unsigned with int, or char with int.
Comment 2 Andrew Pinski 2005-07-12 15:16:35 UTC
(In reply to comment #1)
> Confirmed. Reduced testcase:
Reduced testcase which fails everywhere (even on 64bit targets):
char foo(__SIZE_TYPE__ n)
{
    char c[1][n];
    return c[0][0];
}
======
Here is the backtrace:
#1  0x002eec68 in fancy_abort (file=0x8e8a78 "/Users/pinskia/src/local/gcc/gcc/fold-const.c", 
line=1663, function=0xa08968 "size_binop") at /Users/pinskia/src/local/gcc/gcc/diagnostic.c:590
#2  0x0033c70c in size_binop (code=EXACT_DIV_EXPR, arg0=0x41dba9a0, arg1=0x41d114a0) at /
Users/pinskia/src/local/gcc/gcc/fold-const.c:1662
#3  0x001db4c4 in gimplify_compound_lval (expr_p=0x41dc1c3c, pre_p=0xbfffe8d4, 
post_p=0xbfffe8d8, fallback=fb_rvalue) at /Users/pinskia/src/local/gcc/gcc/gimplify.c:1500
#4  0x001eb2d8 in gimplify_expr (expr_p=0x41dc1c3c, pre_p=0xbfffe8d4, post_p=0xbfffe8d8, 
gimple_test_f=0x3e8364 <is_gimple_val>, fallback=fb_rvalue) at /Users/pinskia/src/local/gcc/gcc/
gimplify.c:3978
#5  0x001ebbb0 in gimplify_expr (expr_p=0x41dbcef0, pre_p=0xbfffe8d4, post_p=0xbfffe8d8, 
gimple_test_f=0x3e72fc <is_gimple_reg_rhs>, fallback=fb_rvalue) at /Users/pinskia/src/local/gcc/
gcc/gimplify.c:4072
#6  0x001e6b10 in gimplify_modify_expr (expr_p=0xbfffe9f8, pre_p=0xbfffe8d4, post_p=0xbfffe8d8, 
want_value=0 '\0') at /Users/pinskia/src/local/gcc/gcc/gimplify.c:3154
Comment 3 Andrew Pinski 2005-08-08 18:11:33 UTC
Hmm, this worked with 20041211.
Comment 4 GCC Commits 2005-08-08 21:38:29 UTC
Subject: Bug 22439

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2005-08-08 21:38:25

Modified files:
	gcc            : ChangeLog gimplify.c 

Log message:
	PR 22439
	* gimplify.c (gimplify_one_sizepos): Preserve the original type.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9682&r2=2.9683
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&r1=2.143&r2=2.144

Comment 5 GCC Commits 2005-08-08 21:39:28 UTC
Subject: Bug 22439

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	rth@gcc.gnu.org	2005-08-08 21:39:18

Modified files:
	gcc            : ChangeLog gimplify.c 

Log message:
	PR 22439
	* gimplify.c (gimplify_one_sizepos): Preserve the original type.

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.359&r2=2.7592.2.360
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.8&r2=2.113.2.9

Comment 6 Richard Henderson 2005-08-08 21:47:42 UTC
Fixed.
Comment 7 Giovanni Bajo 2005-08-10 13:49:20 UTC
No testcase was added, so reopening this until the testcase is committed.
Comment 8 Andrew Pinski 2005-08-26 15:05:09 UTC
I am handling the testcase.
Comment 9 GCC Commits 2005-08-26 15:13:27 UTC
Subject: Bug 22439

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	pinskia@gcc.gnu.org	2005-08-26 15:13:19

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: vla-3.c 

Log message:
	2005-08-26  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/22439
	* gcc.dg/vla-3.c: New test.

Patches:
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.350&r2=1.5084.2.351
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/vla-3.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 10 Andrew Pinski 2005-08-26 15:14:21 UTC
Fixed.
Comment 11 GCC Commits 2005-08-26 15:14:26 UTC
Subject: Bug 22439

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-08-26 15:14:14

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: vla-3.c 

Log message:
	2005-08-26  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR middle-end/22439
	* gcc.dg/vla-3.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5963&r2=1.5964
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/vla-3.c.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 12 Jason Merrill 2006-02-09 09:54:42 UTC
Subject: Bug 22439

Author: jason
Date: Thu Feb  9 09:54:36 2006
New Revision: 110789

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110789
Log:
        PR c++/25979
        * tree.def: Elaborate on difference from MODIFY_EXPR.
        * doc/c-tree.texi (INIT_EXPR): Likewise.
        * gimplify.c (internal_get_tmp_var): Use INIT_EXPR.
        (gimplify_decl_expr, gimplify_init_ctor_eval): Likewise.
        (gimplify_target_expr): Likewise.
        (gimplify_cond_expr): Remove target handling.
        (gimplify_modify_expr): Don't clobber INIT_EXPR code here.
        (gimplify_expr): Clobber it here.
        (gimplify_modify_expr_rhs): Push assignment into COND_EXPR here.
        Do return slot optimization if we have an INIT_EXPR.

        PR tree-opt/24365
        * tree-inline.c (declare_return_variable): Also clear
        DECL_COMPLEX_GIMPLE_REG_P as needed in the modify_dest case.

        PR c++/16405
        * gimplify.c (gimplify_modify_expr_rhs): Re-enable *& handling.

        PR middle-end/22439
        * gimplify.c (gimplify_one_sizepos): Fix typo.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-gimplify.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/doc/c-tree.texi
    trunk/gcc/gimplify.c
    trunk/gcc/testsuite/g++.dg/opt/temp1.C
    trunk/gcc/tree-inline.c
    trunk/gcc/tree.def

Comment 13 Jason Merrill 2006-02-10 17:32:15 UTC
Subject: Bug 22439

Author: jason
Date: Fri Feb 10 17:32:10 2006
New Revision: 110838

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110838
Log:
        PR c++/25979
        * tree.def: Elaborate on difference from MODIFY_EXPR.
        * doc/c-tree.texi (INIT_EXPR): Likewise.
        * gimplify.c (internal_get_tmp_var): Use INIT_EXPR.
        (gimplify_decl_expr, gimplify_init_ctor_eval): Likewise.
        (gimplify_target_expr): Likewise.
        (gimplify_cond_expr): Remove target handling.
        (gimplify_modify_expr): Don't clobber INIT_EXPR code here.
        (gimplify_expr): Clobber it here.
        (gimplify_modify_expr_rhs): Push assignment into COND_EXPR here.
        Do return slot optimization if we have an INIT_EXPR.

        PR tree-opt/24365
        * tree-inline.c (declare_return_variable): Also clear
        DECL_COMPLEX_GIMPLE_REG_P as needed in the modify_dest case.

        PR c++/16405
        * gimplify.c (gimplify_modify_expr_rhs): Re-enable *& handling.

        PR middle-end/22439
        * gimplify.c (gimplify_one_sizepos): Fix typo.

Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/cp-gimplify.c
    branches/gcc-4_1-branch/gcc/cp/typeck2.c
    branches/gcc-4_1-branch/gcc/doc/c-tree.texi
    branches/gcc-4_1-branch/gcc/gimplify.c
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/opt/temp1.C
    branches/gcc-4_1-branch/gcc/tree-inline.c
    branches/gcc-4_1-branch/gcc/tree.def

Comment 14 Jason Merrill 2006-02-11 00:19:35 UTC
Subject: Bug 22439

Author: jason
Date: Sat Feb 11 00:19:30 2006
New Revision: 110864

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110864
Log:
        PR c++/25979
        * tree.def: Elaborate on difference from MODIFY_EXPR.
        * doc/c-tree.texi (INIT_EXPR): Likewise.
        * cp/cp-gimplify.c (cp_gimplify_expr): Don't call
        cp_gimplify_init_expr for MODIFY_EXPRs.
        * cp/typeck2.c (split_nonconstant_init_1): Use INIT_EXPR.
        * gimplify.c (internal_get_tmp_var): Likewise.
        (gimplify_decl_expr, gimplify_init_ctor_eval): Likewise.
        (gimplify_target_expr): Likewise.
        (gimplify_cond_expr): Remove target handling.
        (gimplify_modify_expr): Don't clobber INIT_EXPR code here.
        (gimplify_expr): Clobber it here.
        (gimplify_modify_expr_rhs): Push assignment into COND_EXPR here.
        Do return slot optimization if we have an INIT_EXPR.

        PR middle-end/22439
        * gimplify.c (gimplify_one_sizepos): Fix typo.

Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/cp-gimplify.c
    branches/gcc-4_0-branch/gcc/cp/typeck2.c
    branches/gcc-4_0-branch/gcc/doc/c-tree.texi
    branches/gcc-4_0-branch/gcc/gimplify.c
    branches/gcc-4_0-branch/gcc/tree.def