This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Issues with testsuite on constant pointer arithmetics


On Wed, May 06, 2009 at 01:23:57PM -0700, Ian Lance Taylor wrote:

> Stelian Pop <stelian@popies.net> writes:
> 
> > I did spent a few hours looking but haven't had much luck.
> >
> > I tried tracing this one:
> >> > 	6 long i = s.f-&s.b;
> > and noticed that the pointers gets casted to 'long' (so they become integers
> > and no longer pointers) before the actual substraction is made.
> >
> > Of course, replacing the 'long' with 'int' (on the incriminated targets,
> > where the real size of the pointer is 16 bit, the size of an 'int') makes
> > the code compile as a charm.
> 
> I took a quick look at a similar case for x86, and the key step seems to
> be a call to ptr_difference_const.  It converts the difference of two
> ADDR_EXPRs to a constant.

in my case ptr_difference_const doesn't get called at all, because
the operands are no longer ADDR_EXPRs:

(gdb) p debug_tree(op0)
 <nop_expr 0xb7cfd120
    type <integer_type 0xb7c9d3a8 long int public SI
        size <integer_cst 0xb7c904b4 constant invariant 32>
        unit size <integer_cst 0xb7c90230 constant invariant 4>
        align 8 symtab 0 alias set -1 canonical type 0xb7c9d3a8 precision 32 min
<integer_cst 0xb7c90460 -2147483648> max <integer_cst 0xb7c9047c 2147483647>
        pointer_to_this <pointer_type 0xb7ca7478>>
    constant invariant
    arg 0 <convert_expr 0xb7cfd100
        type <integer_type 0xb7c9d2d8 int public HI
            size <integer_cst 0xb7c9039c constant invariant 16>
            unit size <integer_cst 0xb7c903b8 constant invariant 2>
            align 8 symtab 0 alias set -1 canonical type 0xb7c9d2d8 precision 16
min <integer_cst 0xb7c903f0 -32768> max <integer_cst 0xb7c9040c 32767>
            pointer_to_this <pointer_type 0xb7ca4680>>
        constant invariant
        arg 0 <addr_expr 0xb7cfd080 type <pointer_type 0xb7cfa7b8>
            constant invariant
            arg 0 <component_ref 0xb7c99050 type <array_type 0xb7cfa750>
                arg 0 <var_decl 0xb7c980b0 s> arg 1 <field_decl 0xb7d050b8 f>>>>>

(gdb) p debug_tree(op1)
 <nop_expr 0xb7cfd0e0
    type <integer_type 0xb7c9d3a8 long int public SI
        size <integer_cst 0xb7c904b4 constant invariant 32>
        unit size <integer_cst 0xb7c90230 constant invariant 4>
        align 8 symtab 0 alias set -1 canonical type 0xb7c9d3a8 precision 32 min
<integer_cst 0xb7c90460 -2147483648> max <integer_cst 0xb7c9047c 2147483647>
        pointer_to_this <pointer_type 0xb7ca7478>>
    constant invariant
    arg 0 <convert_expr 0xb7cfd0c0
        type <integer_type 0xb7c9d2d8 int public HI
            size <integer_cst 0xb7c9039c constant invariant 16>
            unit size <integer_cst 0xb7c903b8 constant invariant 2>
            align 8 symtab 0 alias set -1 canonical type 0xb7c9d2d8 precision 16
min <integer_cst 0xb7c903f0 -32768> max <integer_cst 0xb7c9040c 32767>
            pointer_to_this <pointer_type 0xb7ca4680>>
        constant invariant
        arg 0 <addr_expr 0xb7cfd060 type <pointer_type 0xb7ca6f70>
            constant invariant
            arg 0 <component_ref 0xb7c99078 type <integer_type 0xb7c9d1a0 char>
                arg 0 <var_decl 0xb7c980b0 s> arg 1 <field_decl 0xb7d0505c b>>>>>

-- 
Stelian Pop <stelian@popies.net>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]