Bug 52443 - ICE: verify_gimple failed: invalid types in nop conversion
Summary: ICE: verify_gimple failed: invalid types in nop conversion
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: addr-space, ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2012-02-29 22:10 UTC by Georg-Johann Lay
Modified: 2012-03-01 13:36 UTC (History)
2 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-02-29 00:00:00


Attachments
ice-memx.c: C source (86 bytes, text/plain)
2012-02-29 22:11 UTC, Georg-Johann Lay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2012-02-29 22:10:18 UTC
extern void bar (const __memx void*);

void func (char a)
{
    bar (a);
}

const __memx void* func2 (char a)
{
    return a;
}

>> avr-gcc ice-memx.c -S -w

ice-memx.c: In function 'func2':
ice-memx.c:8:20: error: invalid types in nop conversion
const <address-space-7> void *
long int
D.1326 = (const <address-space-7> void *) D.1327;

ice-memx.c:8:20: internal compiler error: verify_gimple failed
Please submit a full bug report,
with preprocessed source if appropriate.


Target: avr
Configured with: ../gcc-trunk/configure --with-gmp=/usr/local --prefix=/usr/local/avr --target=avr --enable-languages=c,c++ --with-dwarf2 --disable-shared --disable-libada --disable-libssp --disable-nls
Thread model: single
gcc version 4.7.0 20120217 (experimental) (GCC) 
GNU C (GCC) version 4.7.0 20120217 (experimental) (avr)
	compiled by GNU C version 4.6.2, GMP version 5.0.4, MPFR version 3.1.0, MPC version 0.9


I can also see the error on a build from 2012-02-28.
Comment 1 Georg-Johann Lay 2012-02-29 22:11:16 UTC
Created attachment 26793 [details]
ice-memx.c: C source
Comment 2 Richard Biener 2012-03-01 09:50:40 UTC
        /* Allow conversions between integral types and pointers only if
           there is no sign or zero extension involved.
           For targets were the precision of ptrofftype doesn't match that
           of pointers we need to allow arbitrary conversions from and
           to ptrofftype.  */
        if ((POINTER_TYPE_P (lhs_type)
             && INTEGRAL_TYPE_P (rhs1_type)
             && (TYPE_PRECISION (lhs_type) >= TYPE_PRECISION (rhs1_type)
                 || ptrofftype_p (rhs1_type)))
            || (POINTER_TYPE_P (rhs1_type)
                && INTEGRAL_TYPE_P (lhs_type)
                && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)
                    || ptrofftype_p (sizetype))))
          return false;

Looks like the above should be

        if ((POINTER_TYPE_P (lhs_type)
             && INTEGRAL_TYPE_P (rhs1_type)
             && (TYPE_PRECISION (lhs_type) <= TYPE_PRECISION (rhs1_type)
                 || ptrofftype_p (rhs1_type)))
            || (POINTER_TYPE_P (rhs1_type)
                && INTEGRAL_TYPE_P (lhs_type)
                && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)
                    || ptrofftype_p (sizetype))))
          return false;

does that help?
Comment 3 Richard Biener 2012-03-01 10:20:20 UTC
Or rather

        /* Allow conversions pointer type to integral type only if
           there is no sign or zero extension involved.
           For targets were the precision of ptrofftype doesn't match that
           of pointers we need to allow arbitrary conversions to ptrofftype.  */
        if (POINTER_TYPE_P (rhs1_type)
            && INTEGRAL_TYPE_P (lhs_type)
            && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)
                || ptrofftype_p (sizetype)))
          return false;

as restricting conversion from integral to pointers does not seem necessary
(only pointers do not have a "sign").
Comment 4 Richard Biener 2012-03-01 10:23:34 UTC
Err ...

        /* Allow conversions pointer type to integral type only if
           there is no sign or zero extension involved.
           For targets were the precision of ptrofftype doesn't match that
           of pointers we need to allow arbitrary conversions to ptrofftype.  */
        if ((POINTER_TYPE_P (lhs_type)
             && INTEGRAL_TYPE_P (rhs1_type))
            || (POINTER_TYPE_P (rhs1_type)
                && INTEGRAL_TYPE_P (lhs_type)
                && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)
                    || ptrofftype_p (sizetype))))
          return false;

tricky business ;)
Comment 5 Richard Biener 2012-03-01 10:24:39 UTC
Mine, in case that helps (it's in tree-cfg.c)
Comment 6 Richard Biener 2012-03-01 12:26:25 UTC
Author: rguenth
Date: Thu Mar  1 12:26:20 2012
New Revision: 184739

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184739
Log:
2012-03-01  Richard Guenther  <rguenther@suse.de>

	PR middle-end/52443
	* tree-cfg.c (verify_gimple_assign_unary): Allow any
	conversions from integral types to pointer types.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-cfg.c
Comment 7 Richard Biener 2012-03-01 12:27:43 UTC
Fixed.
Comment 8 Georg-Johann Lay 2012-03-01 13:36:08 UTC
Yes, thanks. It works now :-)