public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37870]  New: ICE in extract_bit_field_1
@ 2008-10-19 11:48 bernard at brenda-arkle dot me dot uk
  2008-10-19 12:42 ` [Bug middle-end/37870] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: bernard at brenda-arkle dot me dot uk @ 2008-10-19 11:48 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3222 bytes --]

Reproducing this is easy.

cat > ICE.sample.c <<'EOF'
typedef unsigned int size_t;

extern void *memcpy (void *__restrict __dest,
       __const void *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));

unsigned xxx(long double arg)
{
        struct
        {
                char dummy[8];
                unsigned yyy:7;
        } copy;
        memcpy(&copy, &arg, sizeof(copy));
        return copy.yyy;
}
EOF

invoking 'gcc -c -O1 sample.c' then emits
/home/bernard/ICE.sample.c: In function ‘xxx’:
/home/bernard/ICE.sample.c:8: internal compiler error: in extract_bit_field_1,
at expmed.c:1271
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

This is quite sensitive!  Small changes make the ICE
go away.  These include
 using -O0
 re-sizing the array member dummy[] in the struct
 Replacing the memcpy() with an assignment via a
    cast pointer:
       give the struct a tag (e.g., struct fimbulwinter)
       copy = *((struct fimbulwinter *)&arg)
 renaming memcpy() at both occurrences to by-pass the built-in

The last is suggestive, no?

This is NOT a duplicate of bug 37269, though the ICE is reported from
the same function.  I get the same behaviour after applying Andrew
Pinski's patch for that bug.  In fact, I found this bug in an echt
4.3.1 bootstrap build, applied AP's patch, still had it, then used
that compiler to bootstrap a 4.3.2 build, also with AP's patch.
Even using xgcc/cc1 from the stage 1 boostrap build of 4.3.2
showed the bug (there was nothing extra interesting in the
diagnostics produced).

'configure' was invoked with

'../gcc-4.3.2/configure' '--prefix=/usr' '--libexecdir=/usr/lib'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--enable-libada'
'--enable-libssp' '--disable-werror' '--with-mpfr=/usr' '--with-gmp=/usr'
'--with-datarootdir=/usr/share' '--with-docdir=/usr/share/gcc-4.3.2/doc'
'--with-pdfdir=/usr/share/gcc-4.3.2/doc'
'--with-htmldir=/usr/share/gcc-4.3.2/doc/html' '--disable-coverage'
'--enable-nls' '--enable-__cxa_atexit' '--enable-decimal-float'
'--disable-fixed-point' '--enable-threads=posix' '--enable-clocale=gnu'
'--enable-shared' '--disable-intermodule'
'--enable-languages=ada,c++,fortran,java,objc,obj-c++,treelang,c'
'--with-local-prefix=/usr' '--with-gnu-ld' '--with-demangler-in-ld'
'--with-gnu-as' '--with-system-libunwind' '--with-system-zlib'
'--enable-bootstrap'

All those single quotes derive from my build scripts, which quote-and-
escape everything in sight.  The actual CPU is an Athlon64 X2 5600+
(the 2.9GHz flavour, not the 2.8GHz flavour).
My binutils are from release 2.18, built with an unpatched gcc-4.3.1 .


-- 
           Summary: ICE in extract_bit_field_1
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bernard at brenda-arkle dot me dot uk
 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=37870


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
@ 2008-10-19 12:42 ` rguenth at gcc dot gnu dot org
  2008-10-19 12:51 ` rguenth at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-19 12:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-10-19 12:40 -------
Confirmed.

We try to expand

  return (unsigned int) VIEW_CONVERT_EXPR<struct
  {
    char dummy[8];
    <unnamed-unsigned:7> yyy;
  }>(arg).yyy;

which is SRAed from the gimplified memcpy

  copy = VIEW_CONVERT_EXPR<struct
  {
    char dummy[8];
    <unnamed-unsigned:7> yyy;
  }>(arg);

to

<bb 2>:
  copy$yyy_5 = 0;
  copy$dummy$7_6 = VIEW_CONVERT_EXPR<struct
  {
    char dummy[8];
    <unnamed-unsigned:7> yyy;
  }>(arg_4(D)).dummy[7];
...
  SR.9_14 = VIEW_CONVERT_EXPR<struct
  {
    char dummy[8];
    <unnamed-unsigned:7> yyy;
  }>(arg_4(D)).yyy;
  copy$yyy_15 = SR.9_14;
  SR.10_16 = copy$yyy_15;
  D.1204_1 = SR.10_16;
  D.1203_2 = (unsigned int) D.1204_1;
  return D.1203_2;


It seems extract_bitfield_1 doesn't have a fallback path going through memory:

1261      /* Make sure we are playing with integral modes.  Pun with subregs
1262         if we aren't.  */
1263      {
1264        enum machine_mode imode = int_mode_for_mode (GET_MODE (op0));
1265        if (imode != GET_MODE (op0))
(gdb) l
1266          {
1267            if (MEM_P (op0))
1268              op0 = adjust_address (op0, imode, 0);
1269            else
1270              {
1271                gcc_assert (imode != BLKmode);

obviously fails on i?86 with

(gdb) call debug_rtx (op0)
(reg/v:XF 59 [ arg ])

simply not going down this path and relying on the fallback seems to work.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |middle-end
     Ever Confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
      Known to fail|                            |4.3.2 4.4.0
      Known to work|                            |4.2.4
   Last reconfirmed|0000-00-00 00:00:00         |2008-10-19 12:40:45
               date|                            |
            Summary|ICE in extract_bit_field_1  |[4.3/4.4 Regression] ICE in
                   |                            |extract_bit_field_1
   Target Milestone|---                         |4.3.3


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


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
  2008-10-19 12:42 ` [Bug middle-end/37870] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
@ 2008-10-19 12:51 ` rguenth at gcc dot gnu dot org
  2008-10-19 13:58 ` bernard at brenda-arkle dot me dot uk
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-19 12:51 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-10-19 12:40:45         |2008-10-19 12:50:28
               date|                            |


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


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
  2008-10-19 12:42 ` [Bug middle-end/37870] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
  2008-10-19 12:51 ` rguenth at gcc dot gnu dot org
@ 2008-10-19 13:58 ` bernard at brenda-arkle dot me dot uk
  2008-10-19 14:41 ` bernard at brenda-arkle dot me dot uk
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bernard at brenda-arkle dot me dot uk @ 2008-10-19 13:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bernard at brenda-arkle dot me dot uk  2008-10-19 13:57 -------
*** Bug 37872 has been marked as a duplicate of this bug. ***


-- 


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


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (2 preceding siblings ...)
  2008-10-19 13:58 ` bernard at brenda-arkle dot me dot uk
@ 2008-10-19 14:41 ` bernard at brenda-arkle dot me dot uk
  2008-10-22  3:49 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bernard at brenda-arkle dot me dot uk @ 2008-10-19 14:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bernard at brenda-arkle dot me dot uk  2008-10-19 14:39 -------
*** Bug 37873 has been marked as a duplicate of this bug. ***


-- 


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


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (3 preceding siblings ...)
  2008-10-19 14:41 ` bernard at brenda-arkle dot me dot uk
@ 2008-10-22  3:49 ` mmitchel at gcc dot gnu dot org
  2008-10-25 18:44 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2008-10-22  3:49 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


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


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (4 preceding siblings ...)
  2008-10-22  3:49 ` mmitchel at gcc dot gnu dot org
@ 2008-10-25 18:44 ` rguenth at gcc dot gnu dot org
  2008-10-29 15:01 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-25 18:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-10-25 18:43 -------
Patch is wrong, we should go through memory somehow.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|rguenth at gcc dot gnu dot  |unassigned at gcc dot gnu
                   |org                         |dot org
                URL|http://gcc.gnu.org/ml/gcc-  |
                   |patches/2008-               |
                   |10/msg00785.html            |
             Status|ASSIGNED                    |NEW


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


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (5 preceding siblings ...)
  2008-10-25 18:44 ` rguenth at gcc dot gnu dot org
@ 2008-10-29 15:01 ` jakub at gcc dot gnu dot org
  2008-10-29 16:08 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-29 15:01 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2008-
                   |                            |10/msg01236.html
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-10-19 12:50:28         |2008-10-29 15:01:05
               date|                            |


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


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

* [Bug middle-end/37870] [4.3/4.4 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (6 preceding siblings ...)
  2008-10-29 15:01 ` jakub at gcc dot gnu dot org
@ 2008-10-29 16:08 ` jakub at gcc dot gnu dot org
  2008-10-29 16:09 ` [Bug middle-end/37870] [4.3 " jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-29 16:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jakub at gcc dot gnu dot org  2008-10-29 16:07 -------
Subject: Bug 37870

Author: jakub
Date: Wed Oct 29 16:07:39 2008
New Revision: 141430

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141430
Log:
        PR middle-end/37870
        * expmed.c (extract_bit_field_1): If int_mode_for_mode returns
        BLKmode for non-memory, convert using a wider MODE_INT mode
        or through memory.

        * gcc.target/i386/pr37870.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr37870.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expmed.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/37870] [4.3 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (7 preceding siblings ...)
  2008-10-29 16:08 ` jakub at gcc dot gnu dot org
@ 2008-10-29 16:09 ` jakub at gcc dot gnu dot org
  2008-11-05 20:36 ` jakub at gcc dot gnu dot org
  2008-11-05 20:46 ` jakub at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-29 16:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2008-10-29 16:08 -------
Fixed on the trunk so far.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|4.3.2 4.4.0                 |4.3.2
      Known to work|4.2.4                       |4.2.4 4.4.0
            Summary|[4.3/4.4 Regression] ICE in |[4.3 Regression] ICE in
                   |extract_bit_field_1         |extract_bit_field_1


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


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

* [Bug middle-end/37870] [4.3 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (8 preceding siblings ...)
  2008-10-29 16:09 ` [Bug middle-end/37870] [4.3 " jakub at gcc dot gnu dot org
@ 2008-11-05 20:36 ` jakub at gcc dot gnu dot org
  2008-11-05 20:46 ` jakub at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-11-05 20:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2008-11-05 20:35 -------
Subject: Bug 37870

Author: jakub
Date: Wed Nov  5 20:33:54 2008
New Revision: 141618

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141618
Log:
        PR middle-end/37870
        * expmed.c (extract_bit_field_1): If int_mode_for_mode returns
        BLKmode for non-memory, convert using a wider MODE_INT mode
        or through memory.

        * gcc.target/i386/pr37870.c: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr37870.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/expmed.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/37870] [4.3 Regression] ICE in extract_bit_field_1
  2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
                   ` (9 preceding siblings ...)
  2008-11-05 20:36 ` jakub at gcc dot gnu dot org
@ 2008-11-05 20:46 ` jakub at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-11-05 20:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jakub at gcc dot gnu dot org  2008-11-05 20:45 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2008-11-05 20:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-19 11:48 [Bug c/37870] New: ICE in extract_bit_field_1 bernard at brenda-arkle dot me dot uk
2008-10-19 12:42 ` [Bug middle-end/37870] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
2008-10-19 12:51 ` rguenth at gcc dot gnu dot org
2008-10-19 13:58 ` bernard at brenda-arkle dot me dot uk
2008-10-19 14:41 ` bernard at brenda-arkle dot me dot uk
2008-10-22  3:49 ` mmitchel at gcc dot gnu dot org
2008-10-25 18:44 ` rguenth at gcc dot gnu dot org
2008-10-29 15:01 ` jakub at gcc dot gnu dot org
2008-10-29 16:08 ` jakub at gcc dot gnu dot org
2008-10-29 16:09 ` [Bug middle-end/37870] [4.3 " jakub at gcc dot gnu dot org
2008-11-05 20:36 ` jakub at gcc dot gnu dot org
2008-11-05 20:46 ` jakub 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).